Win a copy of Kotlin for Android App Development this week in the Kotlin forum!
  • 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
  • Devaka Cooray
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Junilu Lacar
  • Paul Clapham
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • salvin francis
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Frits Walraven
  • Ganesh Patekar

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.

 
Run away! Run away! Here, take this tiny ad with you:
Programmatically Create PDF Using Free Spire.PDF with Java
https://coderanch.com/wiki/703735/Programmatically-Create-PDF-Free-Spire
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!