aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Question from  Marcus Green mock exam Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Question from  Marcus Green mock exam" Watch "Question from  Marcus Green mock exam" New topic
Author

Question from Marcus Green mock exam

janne s
Ranch Hand

Joined: Sep 21, 2004
Posts: 81
Which of the following represent valid code if it is the entire contents of a file called whitney.java?


1 abstract final class whitney{}
2 public final class whitney extends Object{}
3 public abstract class whitney{}
4 protected class whitney{}

The Correct Answer

2) public final class whitney extends Object{}
3) public abstract class whitney{}


I think answer 2 is wrong. If i'm worng pls explain.

Thank you in advance
jaya
[ November 08, 2004: Message edited by: jaya merugu ]
Toms Liepins
Greenhorn

Joined: Nov 02, 2004
Posts: 21
Hi jaya, i believe that you have not understood the 'final' modifier. Final class/method can not be extended/overriden, however it DOES NOT mean that the final class ITSELF could not extend another nonfinal class. Answer 2 is correct (if you don't believe, try compiling
Krishna Srinivasan
Ranch Hand

Joined: Jul 28, 2003
Posts: 1844

Answer 2,3 are correct.
why answer 2 is wrong. canu you tell the reason?
answer 2 syntax is perfectly valid.


Krishna Srinivasan
Spring Tutorials, OCAJP Mock Questions, 400+ OCPJP Mock Questions
Atul Chandran
Greenhorn

Joined: Oct 24, 2004
Posts: 22
Every class extends Object class implicitly. But explicitly mentioning it does not result in an error. An analogy to instance variables will make it clear.

String a;//a will be assigned null by default.
String b=null;//is legal and null is assigned to b.
similarly
class A{} //A will extend Object by default
class B extends Object {} //legal and B extends Object class.
Marcus Green
arch rival
Rancher

Joined: Sep 14, 1999
Posts: 2813
It may seem a somewhat obscure point to test if you know that everything inherits from Object, even if it is not explicitly stated. However the great ancestor Object class provides some functionality that is used in threading, so it does have a practical application.


SCWCD: Online Course, 50,000+ words and 200+ questions
http://www.examulator.com/moodle/course/view.php?id=5&topic=all
 
 
subject: Question from Marcus Green mock exam