1 What is composition in Java?
Composition is a restricted form of Aggregation in which two entities are highly dependent on each other. It represents part-of relationship. In composition, both entities are dependent on each other. When there is a composition between two entities, the composed object cannot exist without the other entity.
What is method overloading and method overriding?
|Method Overloading||Method Overriding|
|It is used to increase the readability of the program||Provides a specific implementation of the method already in the parent class|
|It is performed within the same class||It involves multiple classes|
What is abstraction in Java?
Data Abstraction is the property by virtue of which only the essential details are displayed to the user. We use abstract class and interface to achieve abstraction.
What is multiple inheritance? Is it supported by Java?
Multiple Inheritance is a feature of object oriented concept, where a class can inherit properties of more than one parent class. The problem occurs when there exist methods with same signature in both the super classes and subclass.
1 What is the life-cycle of a servlet?
Servlet life cycle can be defined as the entire process from its creation till the destruction. The servlet is initialized by calling the init () method. The servlet calls service () method to process a clients request.
What are the different types of inheritance in Java?
Can you override a private or static method in Java?
No, we cannot override private or static methods methods declared as private can never be overridden, they are in-fact bounded during compile time. Private methods in Java are not visible to any other class which limits their scope to the class in which they are declared.
1 What is a copy constructor in Java?
Copy constructor is a special type of constructor that creates an object using another object of the same Java class. It returns a duplicate copy of an existing object of the class. We can assign a value to the final field but the same cannot be done while using the clone() method.
A servlet is a Java programming language class that is used to extend the capabilities of servers that host applications accessed by means of a request-response programming model.
What is runtime polymorphism or dynamic method dispatch?
Runtime polymorphism or Dynamic Method Dispatch is a process in which a call to an overridden method is resolved at runtime rather than compile-time. It is called as through the reference variable of a superclass.
What is the difference between abstract classes and interfaces?
An abstract class allows creating functionality that subclasses can implement or override. An interface only allows defining functionality, not implementing it and whereas a class can extend only one abstract class, it can take advantage of multiple interfaces.
What do you mean by an interface in Java?
An interface in the Java programming language is an abstract type that is used to specify a behavior that classes must implement. It is a collection of abstract methods. A class implements an interface, thereby inheriting the abstract methods of the interface. Method bodies exist only for default methods and static methods.
Accenture – Java Interview Questions
Here is the list Java Interview Questions which are recently asked in Accenture company. These questions are included for both Freshers and Experienced professionals.
Polymorphism is the ability of an object to take many forms. It allows performing the same action in many different ways. Polymorphism in Java has two types: Compile time polymorphism (static binding) and Runtime polymorphism (dynamic binding).