0% found this document useful (0 votes)
110 views

OOP Worksheet

The document contains a worksheet with 50 questions related to object-oriented programming concepts in Java for 4th year information system students. The questions cover topics such as the need for OOP, inheritance, polymorphism, access modifiers, exceptions, abstract classes, interfaces, and more.

Uploaded by

Soll Haile
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
110 views

OOP Worksheet

The document contains a worksheet with 50 questions related to object-oriented programming concepts in Java for 4th year information system students. The questions cover topics such as the need for OOP, inheritance, polymorphism, access modifiers, exceptions, abstract classes, interfaces, and more.

Uploaded by

Soll Haile
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

Werabe University

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 }

49. Does the below code compile successfully?


public class A
{
{
i = 1111;
}

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 }

51. Can you guess the output of the following program?


1
2 public class A
3 {
4 static int methodOne(int i)
5 {
i = i++ + --i;
6
7
return i;
8
}
9
10
static int methodTwo(int i)
11 {
12 i = i-- - ++i + methodOne(i);
13
14 return i;
15 }
16
17 public static void main(String[] args)
18 {
19 int i = 11;
20
21 System.out.println(methodTwo(i) + ++i - --i);
22 }
23 }

52. How many constructors are there in the below class?

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

54. Java’s exception handling mechanism is meant to handle


A only compile time errors
B only syntax errors
C only runtime errors
D both runtime and compile time errors

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?

A. Variable i is used outside the function


B. The code should compile;
C. Cannot use the variable name of j
D. The for loop is infinite

57. What is correct syntax for main method of a java class?


A - public static int main(String[] args)
B - public int main(String[] args)
C - public static void main(String[] args)
D - None of the above

58. Which of the following is not a keyword in java?


A - static
B - Boolean
C - void
C - private
59. What is a class in java?
A - A class is a blue print from which individual objects are created. A class can contain fields
and methods to describe the behavior of an object.
B - class is a special data type.
C - class is used to allocate memory to a data type.
D - none of the above.
60. Primitive variables are stored on Stack.
A - True
B - False
61. Objects are stored on Stack.
A - True
B - False
62. What of the following is the default value of a local variable?
A - null
B-0
C - Depends upon the type of variable
D - Not assigned
63. Can we have multiple classes in same java file?
A - True
B - False
64. Can we have two public classes in one java file?
A - True
B - False
65. We can refer static fields in non-static methods.
A - True
B - False
66. Which of the following is common to all instances of a class?
A) Static fields
B) Non-static methods
C) Static Methods
D) A & C

You might also like