OOP Worksheet
OOP Worksheet
Institute of Technology
Object Oriented Programming Worksheet for 4th year Information System students
1. Why do we need to use OOP?
2. What is multiple inheritance?
3. What is the difference between overloading and overriding?
4. Define protected access modifier.
5. What is the function of a super keyword?
6. What is compile time polymorphism?
7. How can you call a base class method without creating an instance?
8. What is the purpose of ‘this’ keyword?
9. What is an abstract function?
10. How is encapsulation different from data abstraction?
11. Are there any limitations of inheritance? If yes, then what?
12. List down the limitations of Object-Oriented programming.
13. What are the rules of method overloading and overriding in Java?
14. Can we overload a static method in Java?
15. Can we override the static method in Java?
16. Can we prevent overriding a method without using the final modifier?
17. Can we override a private method in Java?
18. Can we override the final method in Java?
19. Can we have a non-abstract method inside an interface?
20. What is an abstract class in Java?
21. What is an interface in Java? What is the real use of an interface?
22. The difference between Abstract class and interface?
23. Can we make a class both final and abstract at the same time?
24. Can we overload or override the main method in Java?
25. Can an interface extend more than one interface in Java?
26. Can a class extend more than one class in Java?
27. Why do we need exception handling in Java?
28. Name the different types of exceptions in Java
29. Describe the difference between unchecked and checked exceptions in Java.
30. What is the difference between finally, final, and finalize in Java?
31. Provide some examples of unchecked exceptions.
32. Give some examples of checked exceptions.
33. Define NumberFormatException exception in Java.
34. What do you understand by ArrayIndexOutOfBoundsException?
35. What happens when an exception is thrown by the main method?
36. What is the difference between the throw and throws keyword in Java?
37. What is a multi-catch block in Java?
38. In OOP, the concept of IS-A is based on _____
39. The term "instance variable" is another name for ___.
40. The term "class variable" is another name for ___.
41. A local variable stores temporary state; it is declared inside a ___.
42. A variable declared within the opening and closing parenthesis of a method signature is
called a ____.
43. What are the eight primitive data types supported by the Java programming language?
44. Character strings are represented by the class ___.
45. An ___ is a container object that holds a fixed number of values of a single type.
46. Can we call super() and this() from a method?
47. Is finally block always get executed in the java program?
48. What is wrong with the below code? Why it is throwing error during compilation?
1 public class A
2 {
3 {
4 System.out.println(i);
5 }
6
7 int i = 10;
8 }
int i;
}
50. Why the below program is showing compile time error?
1 public class A
2 {
3 public static void main(String[] args)
4 {
5 int i;
6
7 System.out.println(i);
8 }
9 }
1 public class A
2 {
3
4 }
53. Which of the following does not deal with exceptions?
A throws
B throw
C finalize
D finally
55. Variables whose values never change (i.e., they are constant) should have names
containing only _____ letters.
A. upper case
B. lower case
C. mixed case
D. numeric
56. Examine the following code. Which answer best describes the scope issue with the
variable i in the final line of code?