Object Oriented Programming in Java: Final Exams
Object Oriented Programming in Java: Final Exams
FINAL EXAMS
INSTRUCTIONS: Answer all questions and make sure you label your answers accordingly.
Copying from each other will cost you dearly. Good luck…
4. Given the following variable definition, define a getter and a setter method for it.
Private int flag = 0;
7. Consider the code below and identify the errors in it. Clearly explain correctly what the
error is in each case.
8. Assume that we defined a class called Generator. How do we create an object of this
class. ANS: Generator G = new Generator();
9. Define an integer array of size 10 and filled is with initial values.
ANS: Int my Array[] = new int [10 ];
My Array [0] = 1;
My Array[1] = 4;
My Array[2] = 5;
My Array [3] = 6;
My Array[4] = 7;
My Array[5] = 3;