permaculture playing cards*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Question from Dan chisholm on abstract class Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Question from Dan chisholm on abstract class" Watch "Question from Dan chisholm on abstract class" New topic
Author

Question from Dan chisholm on abstract class

Rekha Gaikwad
Ranch Hand

Joined: Jul 25, 2005
Posts: 36
abstract class A { // 1
private abstract void m1(); // 2
private abstract class B {} // 3
private class C extends B {} // 4
}

Which line results in a compile-time error?

a. 1
b. 2
c. 3
d. 4
e. None of the above.


Answer on site mention is b


But isn't the answer 'a' is wrong?? Bcz abstract method is declared as private so we can not inherit is so there is no implementation..

and why answer B is correct?
Steve Sugden
Greenhorn

Joined: Aug 20, 2005
Posts: 8
You have the right reason -
"Bcz abstract method is declared as private so we can not inherit is so there is no implementation.."

You can't have an abstract private method because the concrete class can't override that method (an therefore implement it).

So line 2 (b) is where the compiler falls over. Like this

---------- Capture Output ----------
> "C:\j2sdk1.4.2_05\bin\javac.exe" C:\javawork\A.java
C:\javawork\A.java:2: illegal combination of modifiers: abstract and private
private abstract void m1(); // 2
^
1 error
> Terminated with exit code 1.
Arvind Giri
Ranch Hand

Joined: Jun 26, 2005
Posts: 91
Dear Rekha,
You seem right however the root of that error is in line 2. So (b) is right answer.

Am I right?


Regards<br /> <br />Arvind Giri<br />MCA,SCJP 1.4,SCWCD 1.4<br />Looking for SCDJWS
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Question from Dan chisholm on abstract class
 
Similar Threads
Dan's Mock Test on Nested classes
a question about Dan's mock
questions about Dan mock up exam
Abstract Class
abstract