Page 1 of 1
About Question enthuware.ocajp.i.v7.2.1263 :
Posted: Mon Jul 01, 2013 5:24 am
by openmic62
The explanation for this question assumes that the code will exist in a file named "TestClass.java". If this is not true, the code will fail to compile with an additional error:
error: class TestClass is public, should be declared in a file named TestClass.java
Re: About Question enthuware.ocajp.i.v7.2.1263 :
Posted: Mon Jul 01, 2013 6:09 am
by admin
Anything that is not specified in the question should be assumed to be good. This is a standard practice in the real exam as well. It is not possible to specify every possible thing. For example, the question doesn't mention that that the resulting class file is in classpath either, or that jdk is installed.
HTH,
Paul.
Re: About Question enthuware.ocajp.i.v7.2.1263 :
Posted: Thu Nov 21, 2013 8:08 pm
by matheuscs
What about the semicolon after the main? I've made some tests and it seems like I can put semicolons after every single methods and classes.
So.. are the semicolons optional after the methods and classes?
Re: About Question enthuware.ocajp.i.v7.2.1263 :
Posted: Fri Nov 22, 2013 6:25 am
by admin
Semi-colon after methods/classes is a no-op instruction. It has no use but is not an error either.
HTH,
Paul.
Re: About Question enthuware.ocajp.i.v7.2.1263 :
Posted: Sun Apr 13, 2014 5:41 am
by akash701
The file will not compile because TC is a top level class and private is not a valid access modifier for a top level class. private can be applied to an inner class.
If the file will not compile then how come the output is:
"Only "TestClass created" will be printed."
Re: About Question enthuware.ocajp.i.v7.2.1263 :
Posted: Sun Apr 13, 2014 5:56 am
by admin
Not sure what you mean. The correct option is "None of the above" exactly for that reason as explained in the explanation.
Re: About Question enthuware.ocajp.i.v7.2.1263 :
Posted: Sun Jun 01, 2014 9:55 am
by Chandni
OK. But what about public and protected ? They can be applied to top level class unlike private ?
Thanks in adv.
Re: About Question enthuware.ocajp.i.v7.2.1263 :
Posted: Sun Jun 01, 2014 10:19 am
by admin
What did you observe when you tried it out?
Re: About Question enthuware.ocajp.i.v7.2.1263 :
Posted: Thu Aug 14, 2014 8:33 am
by vchhang
Just a thought but I think it would be helpful to include within the explanation that only public and default access modifiers are available to be used with top level class.
Re: About Question enthuware.ocajp.i.v7.2.1263 :
Posted: Thu Aug 14, 2014 9:54 pm
by admin
Good suggestion. Added.
Re: About Question enthuware.ocajp.i.v7.2.1263 :
Posted: Thu Apr 30, 2015 4:55 am
by lucvandewall
Is it correct that this code doesn't compile because it extends an interface rather then implement it?
Re: About Question enthuware.ocajp.i.v7.2.1263 :
Posted: Thu Apr 30, 2015 6:07 pm
by admin
lucvandewall wrote:Is it correct that this code doesn't compile because it extends an interface rather then implement it?
No, where do you see an interface here? Please go through the explanation. It explains why it doesn't compile.