This week's book giveaway is in the Android forum.
We're giving away four copies of Head First Android and have Dawn & David Griffiths on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Tricky Question Cont..... Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Head First Android this week in the Android forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Tricky Question Cont....." Watch "Tricky Question Cont....." New topic

Tricky Question Cont.....

Prasad Ballari
Ranch Hand

Joined: Sep 23, 2000
Posts: 149
(For Information).Just try to answer the below question.Its purely based of fundamentals.
Q)What is the Output of the program.
public class Test{
public static void main(String[] args){
int i=1234;
float f=1.0;
double d= 12.45;
System.out.println("i=" + i + " f= " + f + " d=" + d);
1) i=1234 f=1.0 d=12.45
2) Compilation Error
3) Run time Error
Aru Ven
Ranch Hand

Joined: Sep 28, 2000
Posts: 199
It's simple...... float should be declared as

float f = 1.0F(f) ;
Prasad Ballari
Ranch Hand

Joined: Sep 23, 2000
Posts: 149
yes it is simple, dispite of knowing the answer I did mistake while taking mock test.These small things really can fetch good score for us.
Consider Paul's rocket mass heater.
subject: Tricky Question Cont.....
It's not a secret anymore!