File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes basic question? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "basic question?" Watch "basic question?" New topic
Author

basic question?

rahul mehra
Ranch Hand

Joined: Aug 20, 2007
Posts: 33
Question 1
public class Basics {} // 1
class Basics1 {} // 2
protected class Basics2 {} // 3
private class Basics3 {} // 4
Class Basics4 {} // 5

Suppose these are top-level class declarations and not nested class declarations; and suppose that all of the declarations are contained in one file named Basics.java. Compile-time errors are generated at which lines?

a. 1
b. 2
c. 3
d. 4
e. 5
can anybody help
[ September 04, 2007: Message edited by: Bear Bibeault ]

Thanks
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

Generally, we don't like posting direct answers to questions (see here for why).

What do you think the answer is? Have you tried writing and compiling the file?


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
rahul mehra
Ranch Hand

Joined: Aug 20, 2007
Posts: 33
ok...
see i did try to compile the program....

Question 1
public class Basics {} // 1
class Basics1 {} // 2
protected class Basics2 {} // 3
private class Basics3 {} // 4
Class Basics4 {} // 5

i only got compile time error at line 5 cause the class keyword should have all the characters in small letters....

but the answers say 3 and 4 line will also have compile time error....
marc weber
Sheriff

Joined: Aug 31, 2004
Posts: 11343

Originally posted by deeksha mehra:
...but the answers say 3 and 4 line will also have compile time error...

That's correct. The error is "modifier private/protected not allowed here" (where "here" is a top-level class definition).


"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer
sscce.org
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: basic question?
 
Similar Threads
kahlid question
Which is the first line of a constructor declaration?
SCPJ 1.4 - Dan's questons.. not clear
Dan Question doubt ?
not initialized