• +91 9971497814
  • info@interviewmaterial.com

Computer Interview Questions Answers

Java Interview Questions Answers

Question - 151 : - Why is multiple inheritance not possible in Java?

Answer - 151 : - It depends on how you understand "inheritance". Java can only "extends" one super class, but can "implements" many interfaces; that doesn't mean the multiple inheritance is not possible. You may use interfaces to make inheritance work for you. Or you may need to work around. For example, if you cannot get a feature from a class because your class has a super class already, you may get that class's feature by declaring it as a member field or getting an instance of that class. So the answer is that multiple inheritance in Java is possible.

Question - 152 : - What is a static method?

Answer - 152 : - A static method is a method that belongs to the class rather than any object of the class and doesn't apply to an object or even require that any objects of the class have been instantiated.

Question - 153 : - If a method is declared as protected, where may the method be accessed?

Answer - 153 : - A protected method may only be accessed by classes or interfaces of the same package or by subclasses of the class in which it is declared.

Question - 154 : - What is design by contract?

Answer - 154 : - The design by contract specifies the obligations of a method to any other methods that may use its services and also theirs to it. For example, the preconditions specify what the method required to be true when the method is called. Hence making sure that preconditions are. Similarly, postconditions specify what must be true when the method is finished, thus the called method has the responsibility of satisfying the post conditions. In Java, the exception handling facilities support the use of design by contract, especially in the case of checked exceptions. The assert keyword can be used to make such contracts.

Question - 155 : - What's the difference between J2SDK 1.5 and J2SDK 5.0?

Answer - 155 : - There's no difference, Sun Microsystems just re-branded this version.

Question - 156 : - When a thread blocks on I/O, what state does it enter?

Answer - 156 : - A thread enters the waiting state when it blocks on I/O.

Question - 157 : - What is an abstract method?

Answer - 157 : - An abstract method is a method whose implementation is deferred to a subclass. Or, a method that has no implementation.

Question - 158 : - What are peerless components?

Answer - 158 : - The peerless components are called light weight components.

Question - 159 : - Can an inner class declared inside of a method access local variables of this method?

Answer - 159 : - It's possible if these variables are final.

Question - 160 : - What class is the top of the AWT event hierarchy?

Answer - 160 : - The java.awt.AWTEvent class is the highest-level class in the AWT event-class hierarchy.

Computer Contributors

krishan
Rajeev Katiyar
Yes Baroda

Share your email for latest updates

Name:
Email:

Our partners