• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Question

 
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks. I guess i got confused.
 
Ranch Hand
Posts: 106
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Program will not compile on 1.4

Lave

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

reply
    Bookmark Topic Watch Topic
  • New Topic