This week's book giveaway is in the JavaScript forum.
We're giving away four copies of JavaScript Promises Essentials and have Rami Sarieddine on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Mock Test Que... Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of JavaScript Promises Essentials this week in the JavaScript forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Mock Test Que..." Watch "Mock Test Que..." New topic
Author

Mock Test Que...

Hemant Gupt
Greenhorn

Joined: May 12, 2008
Posts: 26
SOURCE : MARCUS GREEN


Question 8)
What will happen when you attempt to compile and run this code?

private class Base{}

public class Vis{
transient int iVal;
public static void main(String elephant[]){
}
}

1) Compile time error: Base cannot be private
2) Compile time error indicating that an integer cannot be transient
3) Compile time error transient not a data type
4) Compile time error malformed main method

ANS is 1.

Could anyone please explain why it is 1. I think we are not using Base class anywhere in the code.
Mustafa Musaji
Ranch Hand

Joined: May 03, 2008
Posts: 52
It doesn't matter that it's not being used, private is still an illegal access modifier for a top level class. Only public, abstract and final are allowed.


SCJP 5.0 - Passed
Hemant Gupt
Greenhorn

Joined: May 12, 2008
Posts: 26
Thanks for the reply...
But how do we conclude that a class is top-level. ??
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14338
    
  22

If the class is not declared as a nested class inside another class or inside an interface, then it's a top-level class.


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 8 API documentation
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Mock Test Que...