Java Interview Questions and Answers
Question - 111 : - What are use cases?
Answer - 111 : - A use case describes a situation that a program might encounter and what behavior the program should exhibit in that circumstance. It is part of the analysis of a program. The collection of use cases should, ideally, anticipate all the standard circumstances and many of the extraordinary circumstances possible so that the program will be robust.
Question - 112 : - What is scalability and performance?
Answer - 112 : - Performance is a measure of "how fast can you perform this task." and scalability describes how an application behaves as its workload and available computing resources increase.
Question - 113 : - What is the benefit of subclass?
Answer - 113 : - Generally: The sub class inherits all the public methods and the implementation.
The sub class inherits all the protected methods and their implementation.
The sub class inherits all the default(non-access modifier) methods and their implementation.
The sub class also inherits all the public, protected and default member variables from the super class.
The constructors are not part of this inheritance model.
Question - 114 : - How to add menushortcut to menu item?
Answer - 114 : - If you have a button instance called aboutButton, you may add menu short cut by calling aboutButton.setMnemonic('A'), so the user may be able to use Alt+A to click the button.
Question - 115 : - In System.out.println(),what is System,out and println,pls explain?
Answer - 115 : - System is a predefined final class,out is a PrintStream object acting as a field member and println is a built-in overloaded method in the out object.
Question - 116 : - Can you write a Java class that could be used both as an applet as well as an application?
Answer - 116 : - A. Yes. Add a main() method to the applet.
Question - 117 : - Can you make an instance of an abstract class? For example - java.util.Calender is an abstract class with a method getInstance() which returns an instance of the Calender class.
Answer - 117 : - No! You cannot make an instance of an abstract class. An abstract class has to be sub-classed. If you have an abstract class and you want to use a method which has been implemented, you may need to subclass that abstract class, instantiate your subclass and then call that method.
Question - 118 : - What is the output of x > y? a:b = p*q when x=1,y=2,p=3,q=4?
Answer - 118 : - When this kind of question has been asked, find the problems you think is necessary to ask back before you give an answer. Ask if variables a and b have been declared or initialized. If the answer is yes. You can say that the syntax is wrong. If the statement is rewritten as: x
Question - 119 : - What is the difference between Swing and AWT components?
Answer - 119 : - AWT components are heavy-weight, whereas Swing components are lightweight. Heavy weight components depend on the local windowing toolkit. For example, java.awt.Button is a heavy weight component, when it is running on the Java platform for Unix platform, it maps to a real Motif button.
Question - 120 : - Why Java does not support pointers?
Answer - 120 : - Because pointers are unsafe. Java uses reference types to hide pointers and programmers feel easier to deal with reference types without pointers. This is why Java and C-sharp shine.