Monday, May 20, 2013

Java Interview Questions and Answers Part 13

Q111. What is a Container in a GUI?

A Container contains and arranges other components (including other containers) through the use of layout managers, which use specific layout policies to determine where components should go as a function of the size of the container.

Q112. How the object oriented approach helps us keep complexity of software development under control?

We can discuss such issue from the following aspects:
Objects allow procedures to be encapsulated with their data to reduce potential interference.
Inheritance allows well-tested procedures to be reused and enables changes to make once and have effect in all relevant places.
The well-defined separations of interface and implementation allow constraints to be imposed on inheriting classes while still allowing the flexibility of overriding and overloading.

Q113. What is polymorphism?

Polymorphism means "having many forms". It allows methods (may be variables) to be written that needn't be concerned about the specifics of the objects they will be applied to. That is, the method can be specified at a higher level of abstraction and can be counted on to work even on objects of un-conceived classes.

Q114. What is design by contract?

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.

Q115. What are use cases?

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.

Q116. What is scalability and performance?

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.

Q117. What is the benefit of subclass?

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.

Q118. How to add menushortcut to menu item?

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.

Q119. In System.out.println(),what is System,out and println,pls explain?

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.

Q120. Can you write a Java class that could be used both as an applet as well as an application?

Yes. Add a main() method to the applet.

No comments:

Post a Comment

Automatic Traffic Exchange

YallaTech Facebook page