Hi,
First of all, I just wanted to verify that Dan's famous exams are available from
this link:
http://www.danchisholm.net/apr18/comprehensive/index.html. i.e. I just wanted to make sure that I'm attempting the right exams?
2) I gave the first mock exam. I have 2 doubts.
a) Like, what should be the decent score on these mock exams. For e.g.
I got 26/31. Is it decent or really bad? What's the difficulty level
of the real exam compared to those exams?
b) Although I ran the program and verified that the answer is correct
but I can't understand why? In the following code,
why the printS1() of class P is invoked? I thought the context is an object
of class Q. So shouldn't Q's printS1() should be invoked? I know the difference
between static hidden methods and instance overriden methods but still here
we are not invoking the method using reference of type P. If we were invoking
by using P p = new Q() and then p.printS1S2() then I had no problems but ???
Question 25 (mock exam#1):
UBB code
class P {
static void printS1(){System.out.print("P.printS1 ");}
void printS2() {System.out.print("P.printS2 ");}
void printS1S2(){printS1();printS2();}
}
class Q extends P {
static void printS1(){System.out.print("Q.printS1 ");}
void printS2(){System.out.print("Q.printS2 ");}
public static void main(
String[] args) {
new Q().printS1S2();
}
}
What is the result of attempting to compile and run the above program?
ans

rints: P.printS1 Q.printS2
Thanks,
Deep