Pages

Thursday 5 March 2015

JAVA QUESTIONS

Difference between Extends and Implements?
·         When a subclass extends a class, it allows the subclass to inherit (reuse) and override code defined in the supertype.
  • When a class implements an interface, it allows an object created from the class to be used in any context that expects a value of the interface.
Aggregation in Java?
If a class have an entity reference, it is known as Aggregation. Aggregation represents HAS-A relationship.
Consider a situation, Employee object contains many informations such as id, name, emailId etc. It contains one more object named address, which contains its own informations such as city, state, country, zipcode etc.
What is singleton design pattern?
A singleton is a class that is instantiated only once. This is typically accomplished by creating a static field in the class representing the class. A static method exists on the class to obtain the instance of the class and is typically named something such as getInstance(). The creation of the object referenced by the static field can be done either when the class is initialized or the first time that getInstance() is called. The singleton class typically has a private constructor to prevent the singleton class from being instantiated via a constructor. Rather, the instance of the singleton is obtained via the static getInstance() method
Visit:www.sssedu.inhttp://sssedu.in/java-training-in-chennai.html

No comments:

Post a Comment