Given the following source code, which of the lines that are commented out may be reinserted without introducing errors?
Options : 1)final void h(){} //(1) 2)BigBang(int n){m=n} //(2) 3)void k(){i++} //(3) 4)void l(){j++} //(4) 5)abstract void f(); //(0) Correct Answer is 3)void k(){i++} Ok, I agree with the answer. But in addition I even feel that option 5) is right, because even if we insert the line :"abstract void f() in the class Bang, it is valid because Bang has already been declared Abstract. Please let me know whether I am right?
Rob Ross
Bartender
Joined: Jan 07, 2002
Posts: 2205
posted
0
You're right that it would be ok in class Bang, because as you pointed out, it has been declared abstract, and so the method abstract void f(); could be uncommented. However, if you look at the subclass of Bang, BigBang, you will see that there is no method named f(). So if you uncomment that line in Bang, you have an abstract method that is not implemented anywhere, so the compiler won't let you compile the BigBang class unless you mark it abstract. Since BingBang is already declared final in the example, and not abstract, you'd get a compiler error if you uncomment line #0. Rob
Rob
SCJP 1.4
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to
run our stuff on 16 servers instead of 3.