About Question com.enthuware.ets.scjp.v6.2.489 :
Moderator: admin
-
- Posts: 5
- Joined: Wed Nov 21, 2012 12:31 pm
- Contact:
About Question com.enthuware.ets.scjp.v6.2.489 :
Why is "It will throw an AssertionException if 'i' is not equal to 20" not the correct answer ?
-
- Site Admin
- Posts: 10388
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question com.enthuware.ets.scjp.v6.2.489 :
Because the correct name is AssertionError and not AssertionException.
HTH,
Paul.
HTH,
Paul.
Re: About Question com.enthuware.ets.scjp.v6.2.489 :
HI, If I run this It should be throwing assertion error
But In this case it is printing 9 !!
Am I missing something here.? Please reply.
public class AssertTest {
public static void main(String[] args) {
m1();
}
static public void m1()
{
int i = 9;
try{
assert i == 20;
}
catch(Exception e){
i = 20; }
System.out.println(i);
}
}
}
But In this case it is printing 9 !!
Am I missing something here.? Please reply.
public class AssertTest {
public static void main(String[] args) {
m1();
}
static public void m1()
{
int i = 9;
try{
assert i == 20;
}
catch(Exception e){
i = 20; }
System.out.println(i);
}
}
}
Re: About Question com.enthuware.ets.scjp.v6.2.489 :
Forgot to mention taht I have enabled Assertion while running it
Re: About Question com.enthuware.ets.scjp.v6.2.489 :
Never mind...
I had put -ea in program arguments in eclipse.
It shd have been in VM arguments.
I had put -ea in program arguments in eclipse.
It shd have been in VM arguments.
-
- Posts: 3
- Joined: Sat Feb 27, 2016 1:55 pm
- Contact:
Question: About Question com.enthuware.ets.scjp.v6.2.489 :
Why "The program will not compile" is not the answer, since "i" is a local variable and it's not initialized?
-
- Site Admin
- Posts: 10388
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question com.enthuware.ets.scjp.v6.2.489 :
Why do you think it is not initialized when the code clearly says: //code that initializes i goes here
Who is online
Users browsing this forum: No registered users and 15 guests