For this question...
The correct answer is just null not 'null'... because they are different right?
correct me if i am wrong....
About Question enthuware.ocajp.i.v7.2.1153 :
Moderator: admin
-
- Posts: 15
- Joined: Thu Dec 13, 2012 9:44 am
- Contact:
-
- Site Admin
- Posts: 10388
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocajp.i.v7.2.1153 :
Yes, you are right. The single quotes are there just to distinguish between the option statement text and the printed text. There is nothing like like 'null'. There is null or "null".
This has now been added to the option statement to avoid the confusion.
HTH,
Paul.
This has now been added to the option statement to avoid the confusion.
HTH,
Paul.
-
- Posts: 15
- Joined: Sun Jun 01, 2014 8:27 pm
- Contact:
Re: About Question enthuware.ocajp.i.v7.2.1153 :
I noticed this is true within the main method also, not just class fields:
This works fine and '0 null' is printed.
But does not work in any other method - compile time error.
Is there any other situation where default values will be assigned?
Code: Select all
public static void main(String[] args) {
int y;
String s;
System.out.println(x +" "+ s);
}
But does not work in any other method - compile time error.
Is there any other situation where default values will be assigned?
-
- Site Admin
- Posts: 10388
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocajp.i.v7.2.1153 :
I am not sure I understand what you mean. default values are never assigned automatically to local (aka automatic) variables. You must initialize them explicitly.
-Paul.
-Paul.
-
- Posts: 15
- Joined: Sun Jun 01, 2014 8:27 pm
- Contact:
Re: About Question enthuware.ocajp.i.v7.2.1153 :
Sorry, my bad. I was testing this rule in several ways and copied a println statement w/out changing the vars it was printing.
Who is online
Users browsing this forum: Bing [Bot] and 6 guests