Core Java Interview Questions and Answers
<< Previous Question Next Question >>
 Question: 1769 Page Views: 

What is the difference between an if statement and a switch statement?



Posted By: Avi Date: 12 September 2009 08:10:53 PM
 Answer:

The if statement is used to select among two alternatives. It uses a boolean expression to decide which alternative should be executed. The switch statement is used to select among multiple alternatives. It uses an int or string or float expression to determine which alternative should be executed.


Posted By: eTechPlanet


Date: 12 September 2009 08:10:53 PM
Post a better Answer if you have
 
(Will show your Gravatar icon)  
  Country flag

Loading
Enter the text as shown in the image kEvOuv
Related Questions
Core Java : What happens if an exception is not caught?

What happens if an exception is not caught?

An uncaught exception results in the uncaughtException() method of the thread's ThreadGroup being in....
Category: Core Java Date: 11/2/2010 10:16:55 PM
Core Java : What is the result of this code: if("String".trim() == “String")  System.out.println("Equal"); else System.out.println("Not Equal");
Core Java : What is static initializer block?

What is static initializer block?

A static initializer block is a block of code that declares with the static keyword and execute at t....
Category: Core Java Date: 11/2/2010 8:38:51 PM
Core Java : What is the difference between Iterator and Enumeration?

What is the difference between Iterator and Enumeration?

Iterator allows the caller to remove elements from the underlying collection during the iteration wi....
Category: Core Java Date: 11/2/2010 8:05:51 PM
Core Java : What method is invoked to cause an object to begin executing as a separate thread?

What method is invoked to cause an object to begin executing as a separate thread?

The start() method of the Thread class
Category: Core Java Date: 11/2/2010 7:33:49 PM