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.
1. What is Polymorphism?
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).
2. 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.
3. 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.
4. 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.
5. 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.
6. What is inheritance in Java?
Java Inheritance is a mechanism in which one class acquires the property of another class. When an "Is-A" relationship exists between two classes, we use Inheritance. The parent class is called a super class and the inherited class is called a subclass
7. What are the different types of inheritance in Java?
- Single Inheritance
- Multiple Inheritance
- Multilevel Inheritance
- Hierarchical Inheritance
- Hybrid Inheritance
8. 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|
9. 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.
10. 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.
11. What is encapsulation in Java?
Encapsulation is defined as the wrapping up of data under a single unit. It is the mechanism that binds together code and the data it manipulates. It is the process of hiding information details and protecting data and behavior of the object.
12. 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.
13. 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.
14. What is a servlet?
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.
15. 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 client's request.
16. How does cookies work in Servlets?
In cookies technique, we add cookie with response from the servlet. So cookie is stored in the cache of the browser. After that if request is sent by the user, cookie is added with request by default. Thus, we recognize the user as the old user.
TOP MNC's JAVA INTERVIEW QUESTIONS & ANSWERS
Here we listed all Java Interview Questions and Answers which are asked in Top MNCs. Periodically we update this page with recently asked Questions, please do visit our page often and be updated in Java.