DISHA NIRDESHAN

Enlightens your career

Tuesday, June 28, 2011

Questions on Inheritance & polymorphism

QUESTIONS ON INHERITANCE :   Why is multiple inheritance not allowed in java? The reasons for omitting multiple inheritance from the Java language mostly stem from the "simple, object oriented, and familiar" goal. As a simple language, Java's creators wanted a language that most developers could grasp without extensive training. To that end, they worked to make the language as similar to C++ as possible (familiar) without carrying over C++'s unnecessary complexity (simple). In the designers' opinion, multiple inheritance causes more problems and confusion than it solves. So they cut multiple inheritance from the language (just as they cut operator overloading). The designers' extensive C++ experience taught them that multiple inheritance just wasn't worth the headache. Instead,...

Questions on Exceptional Handling

Questions on  Exceptional Handling : Q: What are the different ways to handle exceptions? A:  There are two ways to handle exceptions, 1. By wrapping the desired code in a try block followed by a catch block to catch the exceptions. and 2. List the desired exceptions in the throws clause of the method and let the caller of the method hadle those exceptions.   Q: If I write return at the end of the try block, will the finally block still execute? A: Yes even if you write return as the last statement in the try block and no exception occurs, the finally block will execute. The finally block will execute and then the control return. Q: How to create custom exceptions? A: Your class should extend class Exception, or some more specific type thereof.   Q: If I want...

Questions on Threads

Questions on Threads:   Q: What is Thread ? A :  Thread is a program's path of execution. Every thread has a priority. Threads with higher priority are executed in preference to threads with lower priority. Each thread may or may not also be marked as a daemon. When code running in some thread creates a new Thread object, the new thread has its priority initially set equal to the priority of the creating thread, and is a daemon thread if and only if the creating thread is a daemon. When a Java Virtual Machine starts up, there is usually a single non-daemon thread (which typically calls the method named main of some designated class). The Java Virtual Machine continues to execute threads until either of the following occurs: The exit method of class Runtime has been...

Basic Questions on Core Java

Q:Explain working of Java Virtual Machine (JVM)? A:  JVM is an abstract computing machine like any other real computing machine which first converts .java file into .class file by using Compiler (.class is nothing but byte code file.) and Interpreter reads byte codes.   Q: What is OOPS? A: OOP is the common abbreviation for Object-Oriented Programming.     Q: Describe the principles of OOPS. A: There are three main principals of oops which are called Polymorphism, Inheritance and Encapsulation.     Q: Which class is the superclass of every class? A: Object. Q: Name primitive Java types. A: The 8 primitive types are byte, char, short, int, long, float, double, and boolean. Q: Is main a keyword in Java? A: No, main is not a keyword in Java.  Q:...