Web viewPART III : Language processing, interpretation, translation, the concept of binding,...

29
SNJB’s Late Sau. KBJ COE, Chandwad Department Of Computer Engineering PART III : Language processing, interpretation, translation, the concept of binding, variables, name and scope, Type, l-value, r-value, reference and unnamed variables, routines, generic routines, aliasing and overloading, an abstractsemanticprocessor, run time structure. Casestudy- C run time structure ((MARKS) ) (1/2/3.. .) 1 ((QUESTI ON)) Aliasing in the context of programming ages refers to (GATE CS 2000) ((OPTION _A)) multiple variables having the same ((OPTION _B)) multiple variables having the same value ((OPTION _C)) multiple variables having the same identifier ((OPTION _D)) multiple uses of the same variable ((CORREC T_CHOICE )) (A/B/C/D ) A ((EXPLAN ATION)) Aliasing describes a situation in which a data location in memory can be

Transcript of Web viewPART III : Language processing, interpretation, translation, the concept of binding,...

Page 1: Web viewPART III : Language processing, interpretation, translation, the concept of binding, variables, name and scope, Type, l-value, r-value, reference and

SNJB’s Late Sau. KBJ COE, Chandwad Department Of Computer Engineering

PART III : Language processing, interpretation, translation, the concept of binding, variables, name and scope, Type, l-value, r-value, reference and unnamed variables, routines, generic routines, aliasing and overloading, an abstractsemanticprocessor, run time structure. Casestudy- C run time structure

((MARKS)) (1/2/3...)

1

((QUESTION))

Aliasing in the context of programming languages refers to

((OPTION_A))

multiple variables having the same memory location

((OPTION_B))

multiple variables having the same value

((OPTION_C))

multiple variables having the same identifier

((OPTION_D))

multiple uses of the same variable

((CORRECT_CHOICE)) (A/B/C/D)

A

((EXPLANATION)) (OPTIONAL)

Aliasing describes a situation in which a data location in memory can be accessed through different symbolic names in the program.

((MARKS)) (1/2/3...)

1

((QUESTION))

In the evaluation of a computer language, all of the follow-ing characteristics should be considered except?

((OPTION_A))

Environment : S/w development tools

Page 2: Web viewPART III : Language processing, interpretation, translation, the concept of binding, variables, name and scope, Type, l-value, r-value, reference and

SNJB’s Late Sau. KBJ COE, Chandwad Department Of Computer Engineering

((OPTION_B))

Efficiency

((OPTION_C))

readability

((OPTION_D))

hardware maintainance costs

((CORRECT_CHOICE)) (A/B/C/D)

D

((EXPLANATION)) (OPTIONAL)

No Explanation

((MARKS)) (1/2/3...)

2

((QUESTION))

What is printed by the print statements in the program P1 assuming call by reference parameter passing?

((OPTION_A))

10 , 3

((OPTION_B))

31 , 3

((OPTION_C))

27, 7

((OPTION_D))

None of the above

((CORRECT_CHOICE)) (A/B/C/D)

B

((EXPLANATION)) (OPTIONAL

Note the order in which parameters are passed. Inside func1(), x will actually refer to y of main(); and y and z will refer to x of main(). The Statement y = y + 4; will result in

Page 3: Web viewPART III : Language processing, interpretation, translation, the concept of binding, variables, name and scope, Type, l-value, r-value, reference and

SNJB’s Late Sau. KBJ COE, Chandwad Department Of Computer Engineering

) 14 and statement z = x + y + z will make z = 3 + 14 + 14 = 31 (because y and z point to same variable x of main). Since z refers to x of main(), main will print 31.

((MARKS)) (1/2/3...)

2

((QUESTION))

Consider the following programProgram P2 var n: int: procedure W(var x: int) begin x=x+1; print x; end

procedure D begin var n: int; n=3; W(n); endbegin //beginP2 n=10; D;endIf the language has dynamic scoping and parameters arepassed by reference, what will be printed by the program?

((OPTION_A))

10

((OPTION_B))

11

Page 4: Web viewPART III : Language processing, interpretation, translation, the concept of binding, variables, name and scope, Type, l-value, r-value, reference and

SNJB’s Late Sau. KBJ COE, Chandwad Department Of Computer Engineering

((OPTION_C))

3

((OPTION_D))

None of Above

((CORRECT_CHOICE)) (A/B/C/D)

D

((EXPLANATION)) (OPTIONAL)

Program will print 4.

((MARKS)) (1/2/3...)

1

((QUESTION))

The- results returned by functions under value-result andreference parameter passing conventions

((OPTION_A))

Do not differ

((OTION_B))

Differ in the presence of loops

((OPTION_C))

Differ in all cases

((OPTION_D))

May differ in the presence of exceptions

((CORRECT_CHOICE)) (A/B/C/D)

D

((EXPLANATION)) (OPTIONAL

In call-by-reference evaluation, a function receives an implicit reference to the argument, rather than a copy of its value. This typically means that the function can modify

Page 5: Web viewPART III : Language processing, interpretation, translation, the concept of binding, variables, name and scope, Type, l-value, r-value, reference and

SNJB’s Late Sau. KBJ COE, Chandwad Department Of Computer Engineering

) the argument- something that will be seen by its caller. Note that C doesn’t support call by reference but call-by-reference can be implemented using pointers.Call-by-value-result uses a combination of call-by-value and call-by-reference. Call-by-value-result works by creating local versions of the parameters passed in. However, the values in these local versions are copied back to the original arguments after the end of the procedure.

((MARKS)) (1/2/3...)

1

((QUESTION))

Values that are passed between program and its calledsubroutine are classified as

((OPTION_A))

parameter.

((OTION_B))

argument.

((OPTION_C))

global values.

((OPTION_D))

both a and b.

((CORRECT_CHOICE)) (A/B/C/D)

D

((EXPLANATION)) (OPTIONAL)

Page 6: Web viewPART III : Language processing, interpretation, translation, the concept of binding, variables, name and scope, Type, l-value, r-value, reference and

SNJB’s Late Sau. KBJ COE, Chandwad Department Of Computer Engineering

((MARKS)) (1/2/3...)

1

((QUESTION))

Program subroutines are

((OPTION_A))

called by other programs.

((OTPION_B))

fixed variable.

((OPTION_C))

default constants.

((OPTION_D))

default variables.

((CORRECT_CHOICE)) (A/B/C/D)

A

((EXPLANATION)) (OPTIONAL)

No Explanation

((MARKS)) (1/2/3...)

1

((QUESTION))

Program routine which is used by one or more computer programs is classified as

((OPTION_A))

super-routine.

((OTPION_B))

subroutine.

((OPTION_ dimension routine.

Page 7: Web viewPART III : Language processing, interpretation, translation, the concept of binding, variables, name and scope, Type, l-value, r-value, reference and

SNJB’s Late Sau. KBJ COE, Chandwad Department Of Computer Engineering

C))

((OPTION_D))

array routine.

((CORRECT_CHOICE)) (A/B/C/D)

B

((EXPLANATION)) (OPTIONAL)

No Explanation for this question.

((MARKS)) (1/2/3...)

1

((QUESTION))

Program used for interactive computing is

((OPTION_A))

Translator

((OTPION_B))

Executor

((OPTION_C))

Instructor

((OPTION_D))

Interpreter

((CORRECT_CHOICE)) (A/B/C/D)

D

((EXPLANATION)) (OPTIONAL)

No Explanation for this question.

Page 8: Web viewPART III : Language processing, interpretation, translation, the concept of binding, variables, name and scope, Type, l-value, r-value, reference and

SNJB’s Late Sau. KBJ COE, Chandwad Department Of Computer Engineering

((MARKS)) (1/2/3...)

1

((QUESTION))

Program which translates high level program into machine code is classified as

((OPTION_A))

Compiler.

((OTPION_B))

Translator.

((OPTION_C))

Translating Analyst

((OPTION_D))

instruction analst

((CORRECT_CHOICE)) (A/B/C/D)

A

((EXPLANATION)) (OPTIONAL)

No Explanation for this question.

((MARKS)) (1/2/3...)

1

((QUESTION))

Dynamic binding takes place during

((OPTION_A))

Translation

((OTPION_B))

Linking

((OPTION_C))

Loading the program

Page 9: Web viewPART III : Language processing, interpretation, translation, the concept of binding, variables, name and scope, Type, l-value, r-value, reference and

SNJB’s Late Sau. KBJ COE, Chandwad Department Of Computer Engineering

((OPTION_D))

Execution

((CORRECT_CHOICE)) (A/B/C/D)

D

((EXPLANATION)) (OPTIONAL)

No Explanation for this question.

((MARKS)) (1/2/3...)

1

((QUESTION))

Static binding takes placed during

((OPTION_A))

Translation

((OTPION_B))

Linking

((OPTION_C))

Loading the program

((OPTION_D))

All of the Above

((CORRECT_CHOICE)) (A/B/C/D)

D

((EXPLANATION)) (OPTIONAL)

No Explanation for this question.

Page 10: Web viewPART III : Language processing, interpretation, translation, the concept of binding, variables, name and scope, Type, l-value, r-value, reference and

SNJB’s Late Sau. KBJ COE, Chandwad Department Of Computer Engineering

((MARKS)) (1/2/3...)

1

((QUESTION))

In which of the following mechanisms, types of all variables and expressions are fixed at compilation time.

((OPTION_A))

Strong Typing

((OTPION_B))

Weak Typing

((OPTION_C))

Static Binding/ early binding

((OPTION_D))

Dynamic Binding/ late binding

((CORRECT_CHOICE)) (A/B/C/D)

C

((EXPLANATION)) (OPTIONAL)

No Explanation for this question.

((MARKS)) (1/2/3...)

1

((QUESTION))

In which of the following mechanisms, types of all variables and expressions are not known until runtime

((OPTION_A))

Strong Typing

((OTPION_B))

Weak Typing

((OPTION_C))

Static Binding/ early binding

Page 11: Web viewPART III : Language processing, interpretation, translation, the concept of binding, variables, name and scope, Type, l-value, r-value, reference and

SNJB’s Late Sau. KBJ COE, Chandwad Department Of Computer Engineering

((OPTION_D))

Dynamic Binding/ late binding

((CORRECT_CHOICE)) (A/B/C/D)

D

((EXPLANATION)) (OPTIONAL)

No Explanation for this question.

((MARKS)) (1/2/3...)

1

((QUESTION))

In which of the following mechanisms, types of all variables and expressions are not known until runtime

((OPTION_A))

Strong Typing

((OTPION_B))

Weak Typing

((OPTION_C))

Static Binding/ early binding

((OPTION_D))

Dynamic Binding/ late binding

((CORRECT_CHOICE)) (A/B/C/D)

D

((EXPLANATION)) (OPTIONAL)

No Explanation for this question.

Page 12: Web viewPART III : Language processing, interpretation, translation, the concept of binding, variables, name and scope, Type, l-value, r-value, reference and

SNJB’s Late Sau. KBJ COE, Chandwad Department Of Computer Engineering

((MARKS)) (1/2/3...)

1

((QUESTION))

What is the scope of an external variable?

((OPTION_A))

Whole source file in which it is defined

((OTPION_B))

From the point of declaration to the end of the file in which it is defined

((OPTION_C))

Any source file in a program

((OPTION_D))

From the point of declaration to the end of the file being compiled

((CORRECT_CHOICE)) (A/B/C/D)

D

((EXPLANATION)) (OPTIONAL)

No Explanation for this question.

((MARKS)) (1/2/3...)

1

((QUESTION))

What is the scope of a function?

((OPTION_A))

Whole source file in which it is defined

((OTPION_B))

From the point of declaration to the end of the file in which

Page 13: Web viewPART III : Language processing, interpretation, translation, the concept of binding, variables, name and scope, Type, l-value, r-value, reference and

SNJB’s Late Sau. KBJ COE, Chandwad Department Of Computer Engineering

it is defined

((OPTION_C))

Any source file in a program

((OPTION_D))

From the point of declaration to the end of the file being compiled

((CORRECT_CHOICE)) (A/B/C/D)

D

((EXPLANATION)) (OPTIONAL)

No Explanation for this question.

((MARKS)) (1/2/3...)

1

((QUESTION))

Which variable has the longest scope?

#include <stdio.h> int b; int main() { int c; return 0; } int a;

((OPTION_A))

a

((OTPION_B))

b

((OPTION_C))

c

((OPTION_ Both a and b

Page 14: Web viewPART III : Language processing, interpretation, translation, the concept of binding, variables, name and scope, Type, l-value, r-value, reference and

SNJB’s Late Sau. KBJ COE, Chandwad Department Of Computer Engineering

D))

((CORRECT_CHOICE)) (A/B/C/D)

B

((EXPLANATION)) (OPTIONAL)

No Explanation for this question.

((MARKS)) (1/2/3...)

1

((QUESTION))

Scope of variable is related to definition of variable as:

1. Region of code within which variable value is valid and hence can be accessed.

2. No, relation with region where variable is declared its value is valid in entire scope.

((OPTION_A))

1

((OTPION_B))

2

((OPTION_C))

Both 1 and 2

((OPTION_D))

None

((CORRECT_CHOICE)) (A/B/C/D)

A

((EXPLANATION))

No Explanation for this question.

Page 15: Web viewPART III : Language processing, interpretation, translation, the concept of binding, variables, name and scope, Type, l-value, r-value, reference and

SNJB’s Late Sau. KBJ COE, Chandwad Department Of Computer Engineering

(OPTIONAL)

((MARKS)) (1/2/3...)

1

((QUESTION))

Scope of variable is related to definition of variable as:

1. Region of code within which variable value is valid and hence can be accessed.

2. No, relation with region where variable is declared its value is valid in entire scope.

((OPTION_A))

1

((OTPION_B))

2

((OPTION_C))

Both 1 and 2

((OPTION_D))

None

((CORRECT_CHOICE)) (A/B/C/D)

A

((EXPLANATION)) (OPTIONAL)

No Explanation for this question.

((MARKS)) (1/2/3...)

1

((QUESTION))

A variable that receives an assigned value is called

Page 16: Web viewPART III : Language processing, interpretation, translation, the concept of binding, variables, name and scope, Type, l-value, r-value, reference and

SNJB’s Late Sau. KBJ COE, Chandwad Department Of Computer Engineering

an ................

((OPTION_A))

L-value

((OTPION_B))

R-value

((OPTION_C))

Value

((OPTION_D))

Assignment

((CORRECT_CHOICE)) (A/B/C/D)

A

((EXPLANATION)) (OPTIONAL)

No Explanation for this question.

((MARKS)) (1/2/3...)

1

((QUESTION))

Recursion is sometimes called ..................

((OPTION_A))

Circular definition

((OTPION_B))

Complex definition

((OPTION_C))

Procedure

((OPTION_D))

Union

((CORRECT_CHOICE))

A

Page 17: Web viewPART III : Language processing, interpretation, translation, the concept of binding, variables, name and scope, Type, l-value, r-value, reference and

SNJB’s Late Sau. KBJ COE, Chandwad Department Of Computer Engineering

(A/B/C/D)

((EXPLANATION)) (OPTIONAL)

No Explanation for this question.

((MARKS)) (1/2/3...)

2

((QUESTION))

What will be the output of the following program?

#include<stdio.h>int main(){ int i = 10; printf("%d", ++(-i)); return 0;}

((OPTION_A))

11

((OTPION_B))

10

((OPTION_C))

-9

((OPTION_D))

None

((CORRECT_CHOICE)) (A/B/C/D)

D

((EXPLANATION)) (OPTIONAL)

In C/C++ the pre-increment (decrement) and the post-increment (decrement) operators require an L-value expression as operand. Providing an R-value or a const qualified variable results in compilation error.

Page 18: Web viewPART III : Language processing, interpretation, translation, the concept of binding, variables, name and scope, Type, l-value, r-value, reference and

SNJB’s Late Sau. KBJ COE, Chandwad Department Of Computer Engineering

((MARKS)) (1/2/3...)

2

((QUESTION))

What will be output if you will compile and execute the following c code?

#define max 5;void main(){int i=0;i=max++;printf("%d",i++);}

((OPTION_A))

5

((OTPION_B))

6

((OPTION_C))

R-value required

((OPTION_D))

L-value Required

((CORRECT_CHOICE)) (A/B/C/D)

D

((EXPLANATION)) (OPTIONAL)

It is clear macro constant max has replaced by 5. It is illegal to increment the constant number. Hence compiler will show Lvalue required.

((MARKS)) (1/2/3...)

1

((QUESTION))

Variable which uses same name in whole program and in its all routines thus best classified as

Page 19: Web viewPART III : Language processing, interpretation, translation, the concept of binding, variables, name and scope, Type, l-value, r-value, reference and

SNJB’s Late Sau. KBJ COE, Chandwad Department Of Computer Engineering

((OPTION_A))

Middle variable

((OTPION_B))

Global Variable

((OPTION_C))

Local Variable

((OPTION_D))

Default Varaible

((CORRECT_CHOICE)) (A/B/C/D)

B

((EXPLANATION)) (OPTIONAL)

No Explanation

((MARKS)) (1/2/3...)

1

((QUESTION))

Use of recursion

((OPTION_A))

enhances logical clarity

((OTPION_B))

makes debugging easier

((OPTION_C))

reduces execution time

((OPTION_D))

reduces code size

((CORRECT_CHOICE)) (A/B/C/D)

D

Page 20: Web viewPART III : Language processing, interpretation, translation, the concept of binding, variables, name and scope, Type, l-value, r-value, reference and

SNJB’s Late Sau. KBJ COE, Chandwad Department Of Computer Engineering

((EXPLANATION)) (OPTIONAL)

No Explanation

((MARKS)) (1/2/3...)

1

((QUESTION))

In which of the following parameter passing mechanism, the actual argument has to be a variable?

((OPTION_A))

Pass by value

((OTPION_B))

Pass by result

((OPTION_C))

Pass by value-result

((OPTION_D))

Pass by reference

((CORRECT_CHOICE)) (A/B/C/D)

B

((EXPLANATION)) (OPTIONAL)

No Explanation

((MARKS)) (1/2/3...)

1

((QUESTION))

The generic type in a template function

Page 21: Web viewPART III : Language processing, interpretation, translation, the concept of binding, variables, name and scope, Type, l-value, r-value, reference and

SNJB’s Late Sau. KBJ COE, Chandwad Department Of Computer Engineering

((OPTION_A))

must be T

((OPTION_B))

Can be T

((OPTION_C))

cannot be T for functions you create, but may be for C++'s built-in functions

((OPTION_D))

Cannot be T

((CORRECT_CHOICE)) (A/B/C/D)

B

((EXPLANATION)) (OPTIONAL)

((MARKS)) (1/2/3...)

((QUESTION))

((OPTION_A))

((OPTION_B))

((OPTION_C))

((OPTION_D))

((CORRECT_CHOICE)) (A/B/C/D)

Page 22: Web viewPART III : Language processing, interpretation, translation, the concept of binding, variables, name and scope, Type, l-value, r-value, reference and

SNJB’s Late Sau. KBJ COE, Chandwad Department Of Computer Engineering

((EXPLANATION)) (OPTIONAL)