YouTube Icon

Interview Questions.

Top 100+ Java Programming With Oops Concepts Interview Questions And Answers - May 31, 2020

fluid

Top 100+ Java Programming With Oops Concepts Interview Questions And Answers

Question 1. What Is An Abstract Class?

Answer :

Abstract elegance is a class that has no instances. An summary magnificence is written with the expectation that its concrete subclasses will upload to its structure and conduct, typically through implementing its summary operations.

 

Question 2. What Is A Destructor?

Answer :

Destructor is an operation that frees the country of an object and/or destroys the object itself. In Java, there is no idea of destructors. It’s taken care through the JVM.

J2EE Interview Questions
Question three. What Is A Subclass?

Answer :

Subclass is a class that inherits from one or extra lessons.

Question 4. What Is A Superclass?

Answer :

Superclass is a class from which another class inherits.

J2EE Tutorial
Question five. What Is An Object?

Answer :

Object is an example of a category. It has kingdom, behaviour and identity. It is likewise called as an instance of a class.

Core Java Interview Questions
Question 6. What Is Collaboration?

Answer :

Collaboration is a process whereby numerous items cooperate to offer a few better degree conduct.

Question 7. What Is Meant By Binding?

Answer :

Binding denotes affiliation of a name with a category

Core Java Tutorial C Interview Questions
Question eight. What Is Meant By Dynamic Binding?

Answer :

Dynamic binding is a binding wherein the magnificence association is not made till the item is created at execution time. It is likewise called as overdue binding.

Question nine. What Is Meant By Encapsulation?

Answer :

Encapsulation is the technique of compartmentalizing the factors of an abstraction that defines the structure and conduct. Encapsulation enables to split the contractual interface of an abstraction and implementation.

AJAX Interview Questions
Question 10. What Is Meant By Inheritance?

Answer :

Inheritance is a relationship amongst lessons, in which one elegance shares the structure or behavior defined in another magnificence. This is called Single Inheritance. If a category stocks the shape or behavior from multiple training, then it's miles known as Multiple Inheritance. Inheritance defines “is-a” hierarchy among instructions wherein one subclass inherits from one or greater generalized superclasses.

C Tutorial
Question 11. What Is Meant By Object Oriented Programming?

Answer :

OOP is a technique of programming wherein applications are organized as cooperative collections of items. Each object is an instance of a class and every class belong to a hierarchy.

JSP Interview Questions
Question 12. What Is Meant By Persistence?

Answer :

Persistence is the belongings of an item by using which its life transcends space and time.

J2EE Interview Questions
Question thirteen. What Is Meant By Polymorphism?

Answer :

Polymorphism literally approach taking a couple of shape. Polymorphism is a characteristic of being able to assign a special behavior or value in a subclass, to some thing that become declared in a discern magnificence.

AJAX Tutorial
Question 14. What Is Meant By Abstraction?

Answer :

Abstraction defines the important characteristics of an item that distinguish it from all other forms of objects. Abstraction gives crisply-defined conceptual boundaries relative to the angle of the viewer. It’s the process of focusing on the vital characteristics of an object. Abstraction is one of the fundamental elements of the item version.

Question 15. What Is Meant By Static Binding?

Answer :

Static binding is a binding in which the class affiliation is made throughout compile time. This is also referred to as as early binding.

Java Struts Interview Questions
Question sixteen. What Is Multiple Inheritance And Does Java Support?

Answer :

If a infant class inherits the property from a couple of training is called more than one inheritance. Java does now not allow to increase multiple classes. The problem with with more than one inheritance is if a couple of discern training has a identical approach name, the at runtime it will become diffcult for compiler to determine which technique to execute from the child elegance. To triumph over this problem it allows to implement a couple of Interfaces.

JSP Tutorial
Question 17. What Is Association?

Answer :

Association is a relationship in which all item have their own lifecycle and there's no owner. Let's take an example of Teacher and Student. Multiple college students can accomplice with unmarried teacher and single pupil can partner with multiple teachers however there's no possession among the items and both have their own lifecycle. Both can create and delete independently.

Java Servlets Interview Questions
Question 18. What Is Aggregation?

Answer :

Aggregation is a specialize form of Association in which all object have their own lifecycle however there is possession and baby object can not belongs to any other determine item. Let's take an instance of Department and teacher. A unmarried trainer can not belongs to a couple of departments, however if we delete the branch teacher object will not smash. We can reflect onconsideration on "has-a" relationship.

Core Java Interview Questions
Question 19. What Is Composition?

Answer :

Composition is again specialize form of Aggregation and we will call this as a "dying" dating. It is a sturdy type of Aggregation. Child object dose not have their lifecycle and if figure item deletes all toddler object can also be deleted. Let's take again an instance of dating among House and rooms. House can include a couple of rooms there is no impartial lifestyles of room and any room cannot belongs to two distinct residence if we delete the house room will robotically delete.

Java Servlets Tutorial
Question 20. What Is Difference Between Polymorphism And Inheritance?

Answer :

Inheritance defines parent-baby dating between  training, polymorphism take gain of that relationship to add dynamic behaviour on your code.
Inheritance facilitates in code reusability by means of allowing child class to inherit conduct from the parent magnificence. On the other hand Polymorphism lets in Child to redefine already defined behaviour inside figure magnificence. Without Polymorphism it's not feasible for a Child to execute its own behaviour whilst represented through a Parent reference variable, but with Polymorphism he can try this.
Java doesn't allow multiple inheritance of classes, however lets in a couple of inheritance of Interface, that is definitely require to put into effect Polymorphism. For example a Class can be Runnable, Comparator and Serializable at identical time, due to the fact all 3 are interfaces. This makes them to bypass around in code e.G. You could skip instance of this class to a method which accepts Serializable, or to Collections.Sort() which accepts a Comparator.
Both Polymorphism and Inheritance allow Object oriented programs to adapt. For example, through using Inheritance you can define new consumer types in an Authentication System and by the use of Polymorphism you can take benefit of already written authentication code. Since, Inheritance guarantees minimum base elegance behaviour, a way depending upon tremendous magnificence or terrific interface can nevertheless take delivery of item of base magnificence and might authenticate it.
Hibernate Interview Questions
Question 21. When Super Keyword Is Used?

Answer :

If the approach overrides one among its superclass's strategies, overridden method may be invoked through the usage of the keyword great. It can be also used to consult a hidden subject.

 

Question 22. Does Java Support Multiple Inheritance?

Answer :

No, Java does no longer guide a couple of inheritance. Each magnificence is capable of expand simplest on one elegance, however is capable of put in force a couple of interfaces.

Hibernate Tutorial
Question 23. What Is The Differences Between Abstraction And Encapsulation?

Answer :

Abstraction and encapsulation are complementary concepts. On the one hand, abstraction focuses on the conduct of an item. On the other hand, encapsulation focuses on the implementation of an object’s conduct. Encapsulation is generally finished by way of hiding statistics about the inner kingdom of an item and for that reason, can be visible as a approach used to be able to offer abstraction.

JSTL(JSP Standard Tag Library) Interview Questions
Question 24. Whatt Is Function Overriding And Overloading In Java ?

Answer :

Method overloading in Java occurs while  or greater strategies within the identical elegance have the precise identical call, however one-of-a-kind parameters. On the other hand, method overriding is described as the case whilst a infant class redefines the identical method as a figure class. Overridden strategies should have the same call, argument list, and return kind. The overriding approach may not restriction the get entry to of the method it overrides.

C Interview Questions
Question 25. What Is A Constructor, Constructor Overloading In Java And Copy-constructor?

Answer :

A constructor receives invoked whilst a brand new object is created. Every magnificence has a constructor. In case the programmer does now not provide a constructor for a category, the Java compiler (Javac) creates a default constructor for that class. The constructor overloading is similar to method overloading in Java. Different constructors may be created for a single class. Each constructor have to have its very own specific parameter listing. Finally, Java does assist copy constructors like C++, but the distinction lies within the reality that Java doesn’t create a default copy constructor if you don’t write your very own.

 

Java Tutorial
Question 26. What Is The Difference Between An Interface And An Abstract Class?

Answer :

Java offers and helps the creation both of abstract instructions and interfaces. Both implementations share some common characteristics, but they vary inside the following features:

All methods in an interface are implicitly abstract. On the other hand, an abstract magnificence may also incorporate each summary and non-summary techniques.
A elegance can also put in force a number of Interfaces, however can amplify best one abstract class.
In order for a category to put into effect an interface, it have to enforce all its declared techniques. However, a class may not put in force all declared techniques of an summary elegance. Though, in this case, the sub-elegance must also be declared as summary.
Abstract training can put into effect interfaces with out even imparting the implementation of interface techniques.
Variables declared in a Java interface is by way of default very last. An abstract class may additionally incorporate non-final variables.
Members of a Java interface are public by way of default. A member of an abstract magnificence can both be non-public, included or public.
An interface is in reality abstract and can't be instantiated. An summary magnificence also can not be instantiated, but may be invoked if it carries a primary method.
 

Java Interview Questions
Question 27. What Are Pass By Reference And Pass By Value?

Answer :

When an item is exceeded by cost, which means a copy of the object is passed. Thus, even if modifications are made to that object, it doesn’t affect the unique fee. When an item is passed with the aid of reference, because of this the real object isn't always passed, rather a reference of the item is passed. Thus, any changes made by the external technique, also are meditated in all places.

AJAX Interview Questions
Question 28. What Does The “static” Keyword Mean ? Can You Override Private Or Static Method In Java ?

Answer :

The static key-word denotes that a member variable or approach can be accessed, with out requiring an instantiation of the magnificence to which it belongs. A person cannot override static techniques in Java, due to the fact method overriding is based totally upon dynamic binding at runtime and static techniques are statically binded at bring together time. A static technique isn't always associated with any example of a category so the idea isn't always relevant.

NHibernate Tutorial
Question 29. Can You Access Non Static Variable In Static Context?

Answer :

A static variable in Java belongs to its magnificence and its cost remains the same for all its instances. A static variable is initialized when the magnificence is loaded with the aid of the JVM. If your code attempts to get admission to a non-static variable, with none example, the compiler will whinge, because the ones variables aren't created yet and they're no longer associated with any instance.

NHibernate Interview Questions
Question 30. What Is Runtime Polymorphism?

Answer :

Runtime polymorphism or dynamic technique dispatch is a process wherein a call to an overridden method is resolved at runtime in place of at compile-time.
In this procedure, an overridden method is called thru the reference variable of a splendid class. The dedication of the approach to be referred to as is based on the item being stated by way of the reference variable.
Question 31. What Is The Difference Between Static Binding And Dynamic Binding?

Answer :

In case of static binding kind of item is determined at collect time whereas in dynamic binding sort of object is decided at runtime.

Apache Struts 2 Tutorial
Question 32. What Is Difference Between Object Oriented Programming Language And Object Based Programming Language?

Answer :

Object primarily based programming languages observe all the features of OOPs besides Inheritance. Examples of item primarily based programming languages are JavaScript, VBScript etc.

Apache Struts 2 Interview Questions
Question 33. What Will Be The Initial Value Of An Object Reference Which Is Defined As An Instance Variable?

Answer :

The object references are all initialized to null in Java.

JSP Interview Questions
Question 34. Can We Override Static Method?

Answer :

No, you cannot override the static approach due to the fact they may be the a part of elegance no longer object.

Question 35. Why We Cannot Override Static Method?

Answer :

It is due to the fact the static approach is the a part of magnificence and it's far certain with class whereas example approach is certain with item and static gets memory in magnificence region and example gets memory in heap.

Question 36. Difference Between Method Overloading And Overriding.

Answer :

Method Overloading :

Method overloading increases the clarity of this system.
Approach overlaoding is happens in the elegance.
In this case, parameter have to be specific.
Method Overriding :

Method overriding provides the precise implementation of the approach this is already provided by using its incredible magnificence.
Method overriding occurs in two classes that have IS-A courting.
In this situation, parameter need to be identical.
Java Struts Interview Questions
Question 37. Can You Use Abstract And Final Both With A Method?

Answer :

No, because summary approach wishes to be overridden whereas you can't override very last approach.

Question 38. What Is Blank Or Uninitialized Final Variable?

Answer :

A final variable that isn't initialized at the time of assertion is known as clean final variable.

If you want to create a variable this is initialized on the time of creating item and as soon as initialized might not be modified, it's far useful. For instance PAN CARD variety of an employee. It may be initialized handiest in constructor.

Question 39. What Is Covariant Return Type?

Answer :

The covariant go back type specifies that the go back type may range inside the same course as the subclass.

Before Java5, it became not possible to override any method by using changing the go back type. But now, on the grounds that Java5, it's miles viable to override approach with the aid of changing the return kind if subclass overrides any technique whose return type is Non-Primitive however it changes its go back type to subclass kind.

Question forty. Can There Be Any Abstract Method Without Abstract Class?

Answer :

No, if there may be any summary technique in a class, that elegance have to be abstract.

Java Servlets Interview Questions




CFG