• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

public class

 
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have some doubts about the following questions.
a) A java source file should contain at least one top-level public class.
True or False.
According to a book, I found that a java source file should have at least one public top-level class. You can have a program with a 'default' top level class (ie. no top-level public class) - it compiles and runs . So, what is the answer ?. Somewhere, I saw that this statement this 'false'. So, I am confused.
b) A java source file can have only one public class in it.
True or false
It can have a public inner class too, inside. So, I think, before answering this kind of question, we should search for the word -'top-level-, right ?. I think, this statement is 'false'. Please correct me if I am wrong.
 
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi,
Well according to me u r correct, in first case the answer is false as in the question it is written that a "java source file should have", which i think is wrong as there is no compulsion that u should have a public class.
In second case again the answer is false as u can have inner class public. So i think u have already give the answer
Please correct me if i m wrong.
 
Ranch Hand
Posts: 1070
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Technically you are right, but when it comes to most mock exams when they say class they mean top-level class otherwise they would say inner class.
Another question asked is can you have private, protected or static as a class modifier and the answer is no. However you can have private, protected or static as inner class modifiers.
I think the Sun exam is more exact, but I would assume that if they don't say inner, they mean top-level.
Bill
[This message has been edited by bill bozeman (edited December 06, 2000).]
 
Jini Varghese
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks guys.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic