GeekInterview.com
  I am new, Sign me up!
 
GeekInterview.com  >  Placement Papers  >  I-Flex  >  Technical
Go To First  |  Previous Question  |  Next Question 
 Technical  |  Question 6 of 27    Print  
What is the output of following block of program ?
boolean var = false;
if(var = true) {
System.out.println("TRUE");
} else {
System.out.println("FALSE");
}

(a) TRUE
(b) FALSE
(c) Compilation Error
(d) Run-time Error

(a)
EXPLANATION: The code compiles and runs fine and the 'if' test succeeds because 'var' is set to 'true' (rather than tested for 'true') in the 'if' argument.




  
Total Answers and Comments: 5 Last Update: October 12, 2006   
  
 Sponsored Links

 
 Best Rated Answer

No best answer available. Please pick the good answer available or submit your answer.
August 04, 2005 18:43:46   #1  
SG        

RE: What is the output of following block of program ? boolean var = false; if(var = true) { System.o...
You can have only test condition statements in if statement.So the answers will be -c. Compilation Error.
 
Is this answer useful? Yes | No
December 23, 2005 07:02:26   #2  
nadish kumar Member Since: December 2005   Contribution: 1    

RE: What is the output of following block of program ?...
if only assign the value not compairing so answer is a true
 
Is this answer useful? Yes | No
April 10, 2006 06:22:31   #3  
jacob        

RE: What is the output of following block of program ?...
the output is true since in true is assigned in if statement and the if condition becomes true.
 
Is this answer useful? Yes | No
July 25, 2006 09:56:23   #4  
animesh kalita        

RE: What is the output of following block of program ?...
compilation error.because boolean and var are not defined
 
Is this answer useful? Yes | No
October 12, 2006 02:54:52   #5  
Prasanth Narayan        

RE: What is the output of following block of program ?...
TRUE
 
Is this answer useful? Yes | No


 
Go To Top


 Sponsored Links

 
About Us -  Privacy Policy -  Terms and Conditions -  Contact -  Ask Question -  Propose Category -  Site Updates 

Copyright © 2005 - 2009 GeekInterview.com. All Rights Reserved

Page copy protected against web site content infringement by Copyscape