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.
Question: What is the diffrence between inner class and nested class?
Answer: When a class is defined within a scope od another class, then it becomes inner class.
If the access modifier of the inner class is static, then it becomes nested class.
Question: Diffrence between JRE And JVM AND JDK
Answer: The "JDK" is the Java Development Kit. I.e., the JDK is bundle of software that you can use to develop Java based software. The "JRE" is the Java Runtime Environment. I.e., the JRE is an implementation of the Java Virtual Machine which actually executes Java programs. Typically, each JDK contains one (or more) JRE's along with the various development tools like the Java source compilers, bundling and deployment tools, debuggers, development libraries, etc.
Question: Why is not recommended to have instance variables in Interface
Answer: By Default, All data members and methods in an Interface are public. Having public variables in a class that will be implementing it will be violation of the Encapsulation principal. I hope that's pretty ok.. If anybody has a better framed answer. U r welcome at reema_gupta@intersolutions.stpn.soft.net
Question: Can there be an abstract class with no abstract methods in it?
Answer: Yes
Question: Can an Interface be final?
Answer: No
Question: Can an Interface have an inner class?
Answer: Yes public interface abc { static int i=0; void dd(); class a1 { a1() { int j; System.out.println("in interfia"); }; public static void main(String a1[]) { System.out.println("in interfia"); } } }
Question: Can we define private and protected modifiers for variables in interfaces?
Answer: No
Question: What are some alternatives to inheritance?
Answer: Delegation is an alternative to inheritance. Delegation means that you include an instance of another class as an instance variable, and forward messages to the instance. It is often safer than inheritance because it forces you to think about each message you forward, because the instance is of a known class, rather than a new class, and because it doesn't force
0 comments:
Post a Comment