Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3
1. What is single-level inheritance?
Write a Java program to implement
Single-level inheritance. 2. Explain how an interface is used to achieve multiple Inheritances in Java 3. List out the differences between Class and Interface. Illustrate the usage of interface in java with suitable example 4. Interpret the general form of a class with example. 5. Write a Java program to implement multilevel inheritance with 3 levels of hierarchy. 6. Illustrate with example a super class variable can reference a subclass object 7. Define dynamic method dispatch and write a code snippet in Java to demonstrate. 8. For any class and any method as an example, explain method overriding. 9. What is abstract class and abstract method? Explain with an example. 10. Write your inferences on the below keywords : A) Static B) Final 11. Illustrate the usage of super keyword in Java with suitable example. Also explain the dynamic method dispatch. 12. What will be the output of the below code : class Base { Base() { // Print statement System.out.println( "Base Class Constructor Called "); } } class Derived extends Base { Derived() { System.out.println( "Derived Class Constructor Called "); } } class CallingCons {
public static void main(String[] args)
{ Derived d = new Derived(); } } 13. Compare and contrast method overloading and method overriding with suitable example. 14. Write your inferences on the below keywords : Static Final 15. What are interfaces? What are their benefits? Explain how it is implemented in java with suitable example. 16. What will be the output of the below code :
class Parent { void show() { System.out.println("Parent's show()"); } }
class Overriding { public static void main(String[] args) { Parent obj1 = new Parent(); obj1.show();
Parent obj2 = new Child();
obj2.show(); } } 17. What are super class constructors? How does super class members are used in java. 18. Develop a JAVA program to create a class named shape. Create three sub classes namely: circle, triangle and square, each class has two member functions named draw() and erase (). Demonstrate polymorphism concepts by developing suitable methods, defining member data and main program. 19. What is the importance of the super keyword in inheritance? Illustrate with a suitable example. 20. Develop a Java program to create an abstract class Shape with abstract methods calculateArea() and calculatePerimeter(). Create subclasses Circle and Triangle that extend the Shape class and implement the respective methods to calculate the area and perimeter of each shape. 21. Explain the order of constructor execution in a multilevel class hierarchy 22. Discuss on method overriding in Java with example