Question-21. What is difference between aggregation and composition ?

Answer- Aggregation represents weak relationship whereas composition represents strong relationship. For example: bike has an indicator (aggregation) but bike has an engine (compostion).

Question-22. Why Java does not support pointers ?

Answer- 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.

Question-23. What is super in java ?

Answer- It is a keyword that refers to the immediate parent class object.

Question-24. Can you use this() and super() both in a constructor ?

Answer- No. Because super() or this() must be the first statement.

Question-25. What is object cloning ?

Answer- The object cloning is used to create the exact copy of an object.

Question-26. What is method overloading ?

Answer- 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

Question-27. Why method overloading is not possible by changing the return type in java ?

Answer- Because of ambiguity.

Question-28. Can we overload main() method ?

Answer- Yes, You can have many main() methods in a class by overloading the main method.

Question-29. What is method overriding ?

Answer- 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.

Question-30. Can we override static method ?

Answer- No, you can’t override the static method because they are the part of class not object.