Question: DESIGN AND IMPLEMENTATION OF PROGRAMMING LANGUAGES Question 17 : Based on the following declarations type A: array[1..10]of integer; type B: array[1..10]of integer; Var C: A;

DESIGN AND IMPLEMENTATION OF PROGRAMMING LANGUAGES

Question 17 : Based on the following declarations type A: array[1..10]of integer; type B: array[1..10]of integer; Var C: A; Var Z: B; Assuming whole data operations, what is the correct answer?

a) C=Z is legal, according to name equivalence.

b) C=Z is an error, according to name equivalence.

c) C=Z is legal, according to structure equivalence.

d) a and c.

e) b and c.

------------------------------------------------------------------------------------------------------------------------------

Question 21 : Consider the following two program segments: S1 and S2 S1: Base class: class rational { error() { cout << name()<< endl; } string name() { return "Rational ";} ... } Derived class: class complex: rational { string name() { return "Complex " ;} ... } rational A; complex B; S2: Same as S1, but name is defined as: virtual string name() { return " Rational ";} What is the correct answer?

a) Considering S1, A.error() <= error will call name() in rational and B.error() <=error will call name()in rational.

b) Considering S2: A.error() <= error will call name() in rational and B.error will call name in complex.

c) a and b.

d) In S1 and S2, if error is called, Rational is always printed.

e) none of the mentioned.

---------------------------------------------------------------------------------------------------------------------------------

Question 25 : Assuming static scope, the non local referencing environment at statement1 and statement2 for the following program segment are: Main Var X, Y, Z : real procedure M1( X: real); Var D: real begin M1; call N2 (Y); statement1 end M1; procedure N2( C real); Var D, B: real; begin N2; statement2 end N2; begin main; call MI(A); end main

a) At statement1: Main; M1;N2; Y;Z At Statement2 Main;M1; N2;X;Y;Z.

b) At statement1: Main; M1; N2;Y;Z. At statement2 N2;M1;X.

c) a and b.

d) At Statement1: N2; X; B. At statement2: N2;main;Z.

e) None of the mentioned.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!