Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

PACKAGE,IMPORT,CLASS

 
sheri
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3141
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Ira Jain
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
------------------
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic