About Question enthuware.ocajp.i.v7.2.1263 :

Help and support on OCA OCP Java Programmer Certification Questions
1Z0-808, 1Z0-809, 1Z0-815, 1Z0-816, 1Z0-817

Moderator: admin

Post Reply
openmic62
Posts: 5
Joined: Wed May 01, 2013 5:46 am
Contact:

About Question enthuware.ocajp.i.v7.2.1263 :

Post 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

admin
Site Admin
Posts: 10053
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

Re: About Question enthuware.ocajp.i.v7.2.1263 :

Post 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.
If you like our products and services, please help us by posting your review here.

matheuscs
Posts: 5
Joined: Thu Nov 07, 2013 6:06 pm
Contact:

Re: About Question enthuware.ocajp.i.v7.2.1263 :

Post 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?

admin
Site Admin
Posts: 10053
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

Re: About Question enthuware.ocajp.i.v7.2.1263 :

Post by admin »

Semi-colon after methods/classes is a no-op instruction. It has no use but is not an error either.

HTH,
Paul.
If you like our products and services, please help us by posting your review here.

akash701
Posts: 2
Joined: Sat Apr 12, 2014 8:59 am
Contact:

Re: About Question enthuware.ocajp.i.v7.2.1263 :

Post 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."

admin
Site Admin
Posts: 10053
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

Re: About Question enthuware.ocajp.i.v7.2.1263 :

Post by admin »

Not sure what you mean. The correct option is "None of the above" exactly for that reason as explained in the explanation.
If you like our products and services, please help us by posting your review here.

Chandni
Posts: 6
Joined: Thu May 08, 2014 12:13 pm
Contact:

Re: About Question enthuware.ocajp.i.v7.2.1263 :

Post by Chandni »

OK. But what about public and protected ? They can be applied to top level class unlike private ?

Thanks in adv.

admin
Site Admin
Posts: 10053
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

Re: About Question enthuware.ocajp.i.v7.2.1263 :

Post by admin »

What did you observe when you tried it out?
If you like our products and services, please help us by posting your review here.

vchhang
Posts: 36
Joined: Tue May 06, 2014 8:30 am
Contact:

Re: About Question enthuware.ocajp.i.v7.2.1263 :

Post 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.

admin
Site Admin
Posts: 10053
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

Re: About Question enthuware.ocajp.i.v7.2.1263 :

Post by admin »

Good suggestion. Added.
If you like our products and services, please help us by posting your review here.

lucvandewall
Posts: 2
Joined: Fri Apr 24, 2015 9:04 am
Contact:

Re: About Question enthuware.ocajp.i.v7.2.1263 :

Post by lucvandewall »

Is it correct that this code doesn't compile because it extends an interface rather then implement it?

admin
Site Admin
Posts: 10053
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

Re: About Question enthuware.ocajp.i.v7.2.1263 :

Post 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.
If you like our products and services, please help us by posting your review here.

Post Reply

Who is online

Users browsing this forum: No registered users and 40 guests