About Question enthuware.ocajp.i.v7.2.882 :
Moderator: admin
-
- Posts: 8
- Joined: Wed Sep 10, 2014 2:42 am
- Contact:
About Question enthuware.ocajp.i.v7.2.882 :
I hate those kind of questions because they means nothing in term of checking your knowledge, just to trick people. During the exhausting 120min I can't pay my attention to every trivial single aspect like missing ")" or ";" or "else" and with stupid code formats like
if () {
//bla bla....
}{
//bla bla....
}
If the purpose is to trick people why not just make things simple and write the whole code in one single line to even trick people more??!
And, finally, the font for code in your viewer is very small and hard to see.
if () {
//bla bla....
}{
//bla bla....
}
If the purpose is to trick people why not just make things simple and write the whole code in one single line to even trick people more??!
And, finally, the font for code in your viewer is very small and hard to see.
-
- Site Admin
- Posts: 10054
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocajp.i.v7.2.882 :
Hello,
Missing else is a scenario that is tested on the exam.
Regarding small font: Size of the font is system dependent. You can increase the font how much ever you need by running the viewer with command line argument as explained here: http://enthuware.com/index.php/advanced ... -font-size
HTH,
Paul.
Missing else is a scenario that is tested on the exam.
Regarding small font: Size of the font is system dependent. You can increase the font how much ever you need by running the viewer with command line argument as explained here: http://enthuware.com/index.php/advanced ... -font-size
HTH,
Paul.
If you like our products and services, please help us by posting your review here.
-
- Posts: 8
- Joined: Wed Dec 10, 2014 6:05 am
- Contact:
Re: About Question enthuware.ocajp.i.v7.2.882 :
Yes, I completly agree with thchuong. Imagine what could happen in a drivers license exam? And if the args array is never null why the expression args == null is allowed by the compiler? Language design?
-
- Posts: 1
- Joined: Thu Jul 02, 2015 6:55 pm
- Contact:
Re: About Question enthuware.ocajp.i.v7.2.882 :
So,
if(hasParams){
System.out.println("has params");
}{
System.out.println("no params");
}
This is not an initialization block because it's inside a method?
If that was at members level, it would be an initialization block, therefore being run only when an instance of the class is created, correct?
if(hasParams){
System.out.println("has params");
}{
System.out.println("no params");
}
This is not an initialization block because it's inside a method?
If that was at members level, it would be an initialization block, therefore being run only when an instance of the class is created, correct?
-
- Site Admin
- Posts: 10054
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocajp.i.v7.2.882 :
Yes.broono wrote:So,
if(hasParams){
System.out.println("has params");
}{
System.out.println("no params");
}
This is not an initialization block because it's inside a method?
Correct.If that was at members level, it would be an initialization block, therefore being run only when an instance of the class is created, correct?
If you like our products and services, please help us by posting your review here.
-
- Posts: 19
- Joined: Sun Jul 12, 2015 6:40 am
- Contact:
Re: About Question enthuware.ocajp.i.v7.2.882 :
Is this...
is it that:
in a ternary operator:
if the code before ? resolves as "true":
The value before : is selected.
And if the code before ? resolves as "false"
the value after : is selected.
So that in this case: the value resolves as false (because main's args[] can't be null) so the value after : is selected - which happens to be the value 'true'.
Is that what happened here?
is it that:
in a ternary operator:
if the code before ? resolves as "true":
The value before : is selected.
And if the code before ? resolves as "false"
the value after : is selected.
So that in this case: the value resolves as false (because main's args[] can't be null) so the value after : is selected - which happens to be the value 'true'.
Is that what happened here?
-
- Site Admin
- Posts: 10054
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocajp.i.v7.2.882 :
Yes. Here is a good article explaining this operator: http://alvinalexander.com/java/edu/pj/pj010018Roibeard wrote: if the code before ? resolves as "true":
The value before : is selected.
And if the code before ? resolves as "false"
the value after : is selected.
Yes.So that in this case: the value resolves as false (because main's args[] can't be null) so the value after : is selected - which happens to be the value 'true'.
Is that what happened here?
If you like our products and services, please help us by posting your review here.
-
- Posts: 19
- Joined: Sun Jul 12, 2015 6:40 am
- Contact:
Re: About Question enthuware.ocajp.i.v7.2.882 :
Ok, thank you.
-
- Posts: 31
- Joined: Wed Feb 08, 2017 5:42 pm
- Contact:
Re: About Question enthuware.ocajp.i.v7.2.882 :
Where is written that args is not null?
-
- Site Admin
- Posts: 10054
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocajp.i.v7.2.882 :
Did you read the explanation provided with the question? That is what the question is testing you on. You need to know the fact that args is never null even if no arguments were passed on the command line.AndaRO wrote:Where is written that args is not null?
If you like our products and services, please help us by posting your review here.
-
- Posts: 9
- Joined: Sat Jan 14, 2017 5:01 pm
- Contact:
Re: About Question enthuware.ocajp.i.v7.2.882 :
I just ran some code that involved a code block in the main method.
The code block executed, so code blocks in methods execute whenever the method is run?
The code block executed, so code blocks in methods execute whenever the method is run?
-
- Site Admin
- Posts: 10054
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocajp.i.v7.2.882 :
Yes, that is correct.
If you like our products and services, please help us by posting your review here.
-
- Posts: 202
- Joined: Mon Apr 02, 2018 8:40 am
- Contact:
Re: About Question enthuware.ocajp.i.v7.2.882 :
why is there no mention that this is "Instance Initializer Block". Is it not that?
-
- Site Admin
- Posts: 10054
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocajp.i.v7.2.882 :
No, it is not an instance initializer block because the given block is inside a method.
https://stackoverflow.com/questions/398 ... tion-block
https://stackoverflow.com/questions/398 ... tion-block
If you like our products and services, please help us by posting your review here.
-
- Posts: 202
- Joined: Mon Apr 02, 2018 8:40 am
- Contact:
Re: About Question enthuware.ocajp.i.v7.2.882 :
how is this called?
-
- Site Admin
- Posts: 10054
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocajp.i.v7.2.882 :
It is invoked when the method is executed. It is like any other code in that method.
If you like our products and services, please help us by posting your review here.
Who is online
Users browsing this forum: No registered users and 43 guests