• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Bear Bibeault
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Knute Snortum
  • Junilu Lacar
  • Devaka Cooray
Saloon Keepers:
  • Ganesh Patekar
  • Tim Moores
  • Carey Brown
  • Stephan van Hulst
  • salvin francis
Bartenders:
  • Ron McLeod
  • Frits Walraven
  • Pete Letkeman

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.

 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!