Question+Sets

I will post 6 questions the day the class meets: Each one solve the questions explaining your answer. Each member should answer one question. You cannot solve the same question which has been solved by others. You have to add your feedback/additional explanation/your argument if the answer was wrong...

Here are today's 17.11.2011 questions:

Question 1: Superclass is to subclass as: a. child is to parent b. this is to super c. object is to primitive data d. base class is to derived class e. instance variable is to local variable Shashwat Answer: (D) MISTERUNKNOWN says D

Question 2: Suppose a class M inherits from a class P. In the constructor of M, how would you call the default (no arguments) constructor of P: a. P b. this c. super d. parent e. sub MISTERUNKOWN says D

C- because its superclass! by ishaan, sruti don't delete it!!!!!!!!!!! Question 3: Which of the following does a child class inherit from its parent?: a. public constants b. private variables c. local variables d. private methods e. instance variable is to local variable MISTERUNKOWN says d

Question 4 In this class header, which keyword should go in the blank to creat an inheritance relationship? a. super b. extends c. implements d. inherits e. interface Answer is B !!! extends !!!! done by Seong Jun !!!!!!!!!!!!!!!!!!!!!! :) don't delete !!!!!!!!!!!!!! MISTERUNKNOWN says B

Question 5 Given the classes A and B, class A { void foo { System.out.println("A's foo"); } } class B extends A { void foo { System.out.println("B's foo"); } } What will be the output of the following code? B aRef= new B; aRef.foo; a. A's foo b. B's foo c. There will be a compile error because aRef may only refer to A objects d. There will be a compile error because the compiler cannot tell which foo method is being called e. There will be run time error because the call to foo is ambiguous. MISTERUNKNOWN says D

Question 6 If A inherits from B, B inherits from C, and C inherits from D which of the following is true? a. A is the grandparent of B, C, and D b. D is derived from B c. C may use public variables that are declared in A d. B may use public variables that are declared in A e. A may use public variables that are declared in D MISTERUNKOWN says E