Thursday, February 12, 2009

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

Question :What is the difference between an if statement and a switch statement?
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 expression to determine which alternative should be executed. 198. What is the difference between an Interface and an Abstract class? A: An abstract class can have instance methods that implement a default behavior.An Interface can only declare constants and instance methods, but cannot implement default behavior and all methods are implicitly abstract. An interface has all public members and no implementation. An abstract class is a class which may have the usual flavors of class members (private, protected, etc.), but has some abstract methods.

No comments: