collection of interview question , preparations
Tuesday, November 29, 2011
Core Java Interview Questions :Why would you use a synchronized block vs. synchronized method?
Synchronized blocks place locks for shorter periods than synchronized methods.:I guess, synchronized block or synchronized methods are depends on the user requirements. :First of all to achieve Multithreading mechanism in java we should go for synchronization. And this can be done in two ways depending on the requirement. :There is not a clear advantage of using synchronized method over block.:in some times only some part of the method doesn&
Core Java Interview Questions :Why Runtime Exceptions are Not Checked?
The runtime exception classes (RuntimeException and its subclasses) are exempted from compile-time checking because, in the judgment of the designers of the Java programming language, having to declare such exceptions would not aid significantly in establishing the correctness of programs. Many of the operations and constructs of the Java programming language can result in runtime exceptions. The information available to a compiler, and the level of analysis the compiler performs, are usually not sufficient to establish that such run-time exceptions cannot occur, even though this may be obvious to the programmer. Requiring such exception classes to be declared would simply be an irritation to programmers.
Core Java Interview Questions :Why operator overloading is not there in java?
C++ has proven by example that operator overloading makes code almost impossible to maintain. In fact there very nearly wasn?t even method overloading in Java, but it was thought that this was too useful for some very basic methods like print(). Note that some of the classes like DataOutputStream have unoverloaded methods like writeInt() and writeByte().:I belive Operator Overloading exists in Java.:Operator overloading makes the code more complex and less readable. Also we could define different methods in the same class like plus(),plusplus(), minus() etc and thus bringing operator overloading in Java:I guess,Operator overloading is not supported in Java as its create lot of confusion instead of solving the problems. :Operator Overloading
Core Java Interview Questions :why java uses singly rooted heirarchy?
All objects in Java are inherited from same base class called &
Core Java Interview Questions :Why Errors are Not Checked?
A unchecked exception classes which are the error classes (Error and its subclasses) are exempted from compile-time checking because they can occur at many points in the program and recovery from them is difficult or impossible. A program declaring such exceptions would be pointlessly.:Errors are not predictable at compile time.The problem which halt the execution of program, called error and these are uncheck. So, it is difficult to provide a solution for particular problem.
Core Java Interview Questions :Why does Java not support Multiple Inheritance?
java does not support multiple inheritance because different classes may have different variable with same name that may be be contradicted and can cause confusions resulting in errors.:confusion may not be the problem because we use interface for multiple inheritance so there we will mention function names so the primary reason may be the complexity of holding objects of different datatypes:so that one could get easy view by interfacethat program is using multiple inheritance.Hence to increase readability of code. :Java doesn&
Core Java Interview Questions :Which is superclass of Exception?
"Throwable", the parent class of all exception related classes.: Throwable
Subscribe to:
Posts (Atom)