Core Java Interview Questions with Answers - Part IV
31)What is difference between aggregation and composition?
Aggregation represents weak relationship whereas composition represents strong relationship. For example: bike has an indicator (aggregation) but bike has an engine (compostion).
32)Why Java does not support pointers?
Pointer is a variable that refers to the memory address. They are not used in java because they are unsafe(unsecured) and complex to understand.
33)What is super in java?
It is a keyword that refers to the immediate parent class object.
34)Can you use this() and super() both in a constructor?
No. Because super() or this() must be the first statement.
35)What is object cloning?
The object cloning is used to create the exact copy of an object.
36)What is method overloading?
If a class have multiple methods by same name but different parameters, it is known as Method Overloading. It increases the readability of the program.
37)Why method overloading is not possible by changing the return type in java?
Because of ambiguity.
38) Can we overload main() method?
Yes, ofcourse! You can have many main() methods in a class by overloading the main method.
39)What is method overriding:
If a subclass provides a specific implementation of a method that is already provided by its parent class, it is known as Method Overriding. It is used for runtime polymorphism and to provide the specific implementation of the method.
40)Can we override static method?
No, you can't override the static method because they are the part of class not object.
Search Terms:
java interview questions and answers for experienced
java interview questions and answers for freshers
java interview questions and answers for 3 years experience
java interview questions and answers pdf
java interview questions and answers pdf download
core java interview questions and answers