Object Oriented Programing Through Java (A405303)
Question Bank
Long Questions
1. Explain all the oops concepts in detail.
2. Explain java buzzwords in detail.
3. a) Differentiate between class and object
b) Write a Java program to create a class called “Bank” with instance variables
AccNumber and balance. Implement a parameterized constructor that initializes these
variables with validation:
accountNumber should be non-null and non-empty.
balance should be non-negative.
Print an error message if the validation fails.
(Hint : To print the error message use System.err.println (“Error:
Balance cannot be negative”);
4. Differentiate between method overloading and constructor
overloading. Demonstrate each with an example.
5. a) Can two overloaded methods differ only by return type? Justify with an example
b) Write Java Program to print matrix multiplication of size Three.
6. What is an inner class? Build a program to demonstrate local inner class.
7. Write a program to show how “this” keyword helps in resolving ambiguity
between instance variables and parameters. Extend it by showing how this can
be used to invoke another constructor.
8. Differentiate between this() and super() by illustrating with an example.
9. Give an example where the combination form of inheritance causes ambiguity. Explain
how java handles this ambiguity differently from C++.
10. Write a Java program to implement inheritance to employee class where to add
department number in sub class 1, to add age and social security number in sub class
2, to add address in sub class 3 and name, employee id should be in super class.
11. a) Write a program using Method Overloading (Static Polymorphism) to overload
display () for printing an integer, a float, a double, and a character? (Pass the values
as arguments to the display () from main method).
b) Write a program that uses this keyword to call one constructor from another
12. Define package. Describe the process of importing and accessing a package with
suitable example.
13. Compare specialization and specification in inheritance with suitable examples.
Which one is more prone to violating substitutability, and why?
14. a) Define interface? Write the differences between abstract class and interface?
b) Give the suitable example to demonstrate importance of abstract class and interface.
15. Explain the uses of final keyword in java with suitable examples.
16. What is an exception? Why we need to handle it? Demonstrate try, catch and
finally keywords with an example program.
17. Draw the exception hierarchy in Java starting from Throwable. Explain
why Java distinguishes between checked and unchecked exceptions.
18. What is exception handling? Explain the applications of exception handling
in java. Develop a program on exception handling mechanism.
19. Differentiate between checked and unchecked exception with a suitable example.
20. Suppose you design a base class Shape with subclasses Circle, Square, and Triangle. How
does the Substitution Principle (SP) apply when a subclass violates base class contracts
(e.g., zero area shapes)? Illustrate with code.
21. Explain forms of inheritance each with an example
22. Explain method overriding with sample program.
23. Write a program to demonstrate the usage of method overriding calling super class
constructor in derived class.
24. What do you mean by exception and error? Give the hierarchy of exceptions in java.
25. Give an example where interface can be used to support multiple inheritance.
26. Differentiate between method overloading and method overriding. Explain with an
example program.