Win a copy of Machine Learning Systems: Designs that scale this week in the Scala forum
or Xamarin in Action: Creating native cross-platform mobile apps in the Android forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Question  RSS feed

 
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
src: www.javablackbelt.com

public class test {
public static void main(String[] arg) {
Long val = 4444444L;

if (val > 10) {
System.out.println(">10");
} else {
System.out.println("not sure");
}
}
}

Choices:
>10
not sure
Compilation error at line 3
Compilation error at line 4
None of the above

Ans: >10

I thought answer should be "not sure", as 4444444L would be greater than 10.Please suggest.
 
Ranch Hand
Posts: 190
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Originally posted by Vidya Singh:
src: www.javablackbelt.com

public class test {
public static void main(String[] arg) {
Long val = 4444444L;

if (val > 10) {
System.out.println(">10");
} else {
System.out.println("not sure");
}
}
}

Choices:
>10
not sure
Compilation error at line 3
Compilation error at line 4
None of the above

Ans: >10

I thought answer should be "not sure", as 4444444L would be greater than 10.Please suggest.




As 4444444L is greater than 10, ">10" is printed and rightly so. Please look at the if else construct carefully (If I am not making a mistake )
 
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is your choice Vidya Singh ?
I think you�re making confusion with types !
[ January 16, 2008: Message edited by: Mateus Brum ]
 
Vidya Singh
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks. I guess i got confused.
 
Ranch Hand
Posts: 106
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Program will not compile on 1.4

Lave

Originally posted by Vidya Singh:
Thanks. I guess i got confused.

 
Mo-om! You're embarassing me! Can you just read a tiny ad like a normal person?
Rocket Oven Kickstarter - from the trailboss
https://coderanch.com/t/695773/Rocket-Oven-Kickstarter-trailboss
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!