wood burning stoves 2.0*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Top-level class modifiers? 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 "Top-level class modifiers?" Watch "Top-level class modifiers?" New topic
Author

Top-level class modifiers?

Jason
Ranch Hand

Joined: Dec 06, 2000
Posts: 35
This question appear in IBM mock exam:
I doubt if there is a correct answer:
8)
Which of the following declarations of a top-level class Frog are legal, assuming Animal is an existing class?

a) protected class Frog extends Animal {

b) private class Frog extends Animal {

c) transient class Frog extends Animal {

d) native class Frog extends Animal

Any help will be appreciated!
Ankur Gupta
Ranch Hand

Joined: Jun 13, 2000
Posts: 66
protected and private can't be used with a top level class, as I understand. native and transient also can't be used for a class.
So, looks like we have a question for errata!!
Manish Kumar
Greenhorn

Joined: Jun 27, 2000
Posts: 6
Hi,
Jason
You are right. There isn't any correct answer, because a top-level class can only be public or 'friendly'.
Manish
ryan headley
Ranch Hand

Joined: Jun 28, 2000
Posts: 156
I believe top level classes can have no modifier as well (which is known as default
class Test
{
public static void main(String args[])
{
System.out.println("Hello World!");
}
}
That should compile and print out Hello World. The class in this case is not public private or protected, but it is default.


Ryan Headley<br /><a href="http://www.sudovi.com" target="_blank" rel="nofollow">http://www.sudovi.com</a>
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Top-level class modifiers?
 
Similar Threads
IBM's Mock Exam
Classes
Exceptions
bout top-level class
Inheritance - Mock Question & Explanation on Dan Chisholm's website.