import static java.lang.System.*;

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

Moderator: admin

Post Reply
Shri Shri
Posts: 5
Joined: Sun May 21, 2017 9:01 pm
Contact:

import static java.lang.System.*;

Post by Shri Shri »

Although i got my answer right because 3 incorrect options started with "static import...", i am not clear with why option import static java.lang.System.*; is correct.

Also clear that we have to import all static elements of that class or explicitly mention the member name like
static java.lang.Integer.MAX_VALUE.

But what is significance of import static java.lang.System.*;

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

Re: import static java.lang.System.*;

Post by admin »

Did you read the explanation given with this option -
The code uses out.println instead of System.out.println. out is a static field in java.lang.System class. That is why you need to import the static fields of java.lang.System.

Post Reply

Who is online

Users browsing this forum: No registered users and 4 guests