• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

PACKAGE,IMPORT,CLASS

 
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 3141
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
------------------
 
Would you turn that thing down? I'm controlling a mind here! Look ... look at the tiny ad ...
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic