File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes PACKAGE,IMPORT,CLASS 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 "PACKAGE,IMPORT,CLASS" Watch "PACKAGE,IMPORT,CLASS" New topic
Author

PACKAGE,IMPORT,CLASS

sheri
Ranch Hand

Joined: Sep 14, 2000
Posts: 43
What can you add at //?
//
public class Test {
}
A.package myprog;
B.import java.AWT.*;
C.protected class Prot {}
D.class Another {}
E.public static int myData = 123;

please ans:
my ans
A,B,D
the order is package,import,class
can anybody explain :can class put before public class in a file?
CAN ANYBODY GIVE ME THE CORRECT ANS:
THANX
SSHERIN
Jane Griscti
Ranch Hand

Joined: Aug 30, 2000
Posts: 3141
Hi Sheri,
If you try to compile the code with the answers added in you get the following errors:

So, the correct answer is A, D
Hope that helps

Jane Griscti
SCJP, Co-author Mike Meyers' Java 2 Certification Passport
Ira Jain
Ranch Hand

Joined: Sep 06, 2000
Posts: 70
Hi ,
You can put a non-public class before a public class. The only rule is that there should be only one public class per java file.
Ira
------------------
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: PACKAGE,IMPORT,CLASS
 
Similar Threads
Is Protected Method is accessible?
about import
import questions K&B page 138
about import
overriding