PRELIM EXAM - UGRD-CS6203C Object Oriented Programming
PRELIM EXAM - UGRD-CS6203C Object Oriented Programming
Question 1
Incorrect
a. None of These
b. Integers
c. Both A and B
Question 2
Incorrect
b. A constructor must have the same name as the class it is declared within
https://trimestralexam.amaesonline.com/2233/mod/quiz/review.php?attempt=49926&cmid=1690&showall=1 1/18
6/19/23, 8:47 AM PRELIM EXAM: Attempt review
Question 3
Correct
Consider the following class definition: public class MyClass { private int value; public void setValue(int i){ /* code */ } // Other methods... } The
method setValue assigns the value of i to the instance field value. What could you write for the implementation of setValue?
a. value = i;
b. this.value = i;
c. value == i;
Question 4
Incorrect
A constructor
https://trimestralexam.amaesonline.com/2233/mod/quiz/review.php?attempt=49926&cmid=1690&showall=1 2/18
6/19/23, 8:47 AM PRELIM EXAM: Attempt review
Question 5
Correct
class Paint {
// all methods have same name
b. Method overriding
c. Constructor overloading
d. Method overloading
Question 6
Incorrect
a. Character
b. Integer
c. Boolean
d. Float
https://trimestralexam.amaesonline.com/2233/mod/quiz/review.php?attempt=49926&cmid=1690&showall=1 3/18
6/19/23, 8:47 AM PRELIM EXAM: Attempt review
Question 7
Correct
a. Null
b. 1
c. 0
d. Garbage value
Question 8
Correct
What is the output of the following program: public class testmeth { static int i = 1; public static void main(String args[]) {
System.out.println(i+” , “); m(i); System.out.println(i); } public void m(int i) { i += 2; } }
a. 1,3
b. 1 , 0
c. 1 , 1
d. 3 , 1
Question 9
Correct
Which statement transfers execution to different parts of your code based on the value of an expression?
a. Nested-if
b. If
c. Switch
d. if-else-if
https://trimestralexam.amaesonline.com/2233/mod/quiz/review.php?attempt=49926&cmid=1690&showall=1 4/18
6/19/23, 8:47 AM PRELIM EXAM: Attempt review
Question 10
Correct
Question 11
Correct
a. friendly
b. public
c. transient
d. private
Question 12
Correct
a. double
b. then
c. case
d. switch
https://trimestralexam.amaesonline.com/2233/mod/quiz/review.php?attempt=49926&cmid=1690&showall=1 5/18
6/19/23, 8:47 AM PRELIM EXAM: Attempt review
Question 13
Correct
Question 14
Correct
d. A class which is implementing an interface must implement all the methods of the interface.
Question 15
Correct
What is the type and value of the following expression? (Notice the integer division) -4 + 1/2 + 2*-3 + 5.0
a. int -5
b. double -4.5
c. int -4
d. double -5.0
https://trimestralexam.amaesonline.com/2233/mod/quiz/review.php?attempt=49926&cmid=1690&showall=1 6/18
6/19/23, 8:47 AM PRELIM EXAM: Attempt review
Question 16
Correct
What do you call the languages that support classes but not polymorphism?
a. Object-based language
Question 17
Correct
Which variables are created when an object is created with the use of the keyword 'new' and destroyed when the object is destroyed?
a. Static variables
b. Local variables
c. Class Variables
d. Instance variables
Question 18
Correct
a. JVM
b. JAVAC
c. JRE
d. JDH
https://trimestralexam.amaesonline.com/2233/mod/quiz/review.php?attempt=49926&cmid=1690&showall=1 7/18
6/19/23, 8:47 AM PRELIM EXAM: Attempt review
Question 19
Correct
a. Least
b. Highest
c. Equal
d. None of These
Question 20
Correct
In Java code, the line that begins with /* and ends with */ is known as?
a. Both A & B
b. None of these
c. Multiline comment
Question 21
Correct
Consider, public class MyClass { public MyClass(){/*code*/} // more code... } To instantiate MyClass, you would write?
b. MyClass mc = MyClass();
c. MyClass mc = MyClass;
https://trimestralexam.amaesonline.com/2233/mod/quiz/review.php?attempt=49926&cmid=1690&showall=1 8/18
6/19/23, 8:47 AM PRELIM EXAM: Attempt review
Question 22
Incorrect
Consider the following code fragment Rectangle r1 = new Rectangle(); r1.setColor(Color.blue); Rectangle r2 = r1; r2.setColor(Color.red); After
the above piece of code is executed, what are the colors of r1 and r2 (in this order)?
a. Color.red Color.red
b. Color.blue Color.red
c. Color.red Color.blue
d. Color.blue Color.blue
Question 23
Correct
d. A class has always a constructor (possibly automatically supplied by the java compiler).
Question 24
Correct
a. Braces
b. Brackets Brackets
c. Comma
d. Parentheses
https://trimestralexam.amaesonline.com/2233/mod/quiz/review.php?attempt=49926&cmid=1690&showall=1 9/18
6/19/23, 8:47 AM PRELIM EXAM: Attempt review
Question 25
Correct
a. J++
b. Pine
c. Sumatra
d. Oak
Question 26
Correct
a. A private member of a class cannot be accessed by the methods of the same class.
Question 27
Correct
a. "0"
b. '0'
c. "ab" + "cd"
https://trimestralexam.amaesonline.com/2233/mod/quiz/review.php?attempt=49926&cmid=1690&showall=1 10/18
6/19/23, 8:47 AM PRELIM EXAM: Attempt review
Question 28
Correct
Question 29
Correct
b. Constructor overloading
Question 30
Correct
a. Interface
b. A class
c. Method
d. An Array
https://trimestralexam.amaesonline.com/2233/mod/quiz/review.php?attempt=49926&cmid=1690&showall=1 11/18
6/19/23, 8:47 AM PRELIM EXAM: Attempt review
Question 31
Correct
b. A finally block is executed before the catch block but after the try block.
Question 32
Correct
In java control statements break, continue, return, try-catch-finally and assert belongs to?
a. Transfer statements
b. Selection statements
c. Loop Statements
d. Pause Statement
Question 33
Correct
a. *
b. >>
c. ++
d. ()
https://trimestralexam.amaesonline.com/2233/mod/quiz/review.php?attempt=49926&cmid=1690&showall=1 12/18
6/19/23, 8:47 AM PRELIM EXAM: Attempt review
Question 34
Incorrect
a. |=' Operator
b. <=' Operator
c. &' Operator
d. &=' Operator
Question 35
Correct
a. static only
b. protected
d. private
Question 36
Correct
https://trimestralexam.amaesonline.com/2233/mod/quiz/review.php?attempt=49926&cmid=1690&showall=1 13/18
6/19/23, 8:47 AM PRELIM EXAM: Attempt review
Question 37
Correct
c. Java Servlets
Question 38
Correct
Question 39
Correct
a. Long
b. Uppercase L
c. Lowercase L
d. Both A and B
https://trimestralexam.amaesonline.com/2233/mod/quiz/review.php?attempt=49926&cmid=1690&showall=1 14/18
6/19/23, 8:47 AM PRELIM EXAM: Attempt review
Question 40
Incorrect
What will be printed as the output of the following program? public class testincr { public static void main(String args[]) { int i = 0; i = i++ + i;
System.out.println("I = " +i); } }
a. I = 2
b. I = 1
c. I=0
d. I = 3
Question 41
Correct
a. Java
c. C and C++
Question 42
Correct
a. Hello, world!
b. Hello, \nworld!
c. "Hello, \nworld!"
https://trimestralexam.amaesonline.com/2233/mod/quiz/review.php?attempt=49926&cmid=1690&showall=1 15/18
6/19/23, 8:47 AM PRELIM EXAM: Attempt review
Question 43
Incorrect
Consider the two methods (within the same class) public static int foo(int a, String s) { s = "Yellow"; a=a+2; return a; } public static void bar() {
int a=3; String s = "Blue"; a = foo(a,s); System.out.println("a="+a+" s="+s); } public static void main(String args[]) { bar(); } What is printed on
execution of these methods?
a. a = 3 s = Yellow
b. a = 5 s = Yellow
c. a = 5 s = Blue
d. a = 3 s = Blue
Question 44
Correct
Which access type data gets derived as private member in derived class?
a. Protected
b. Public
d. Private
Question 45
Correct
https://trimestralexam.amaesonline.com/2233/mod/quiz/review.php?attempt=49926&cmid=1690&showall=1 16/18
6/19/23, 8:47 AM PRELIM EXAM: Attempt review
Question 46
Correct
Which of the following variable declaration would NOT compile in a java program?
a. int var1;
b. int 1_var;
c. int VAR;
d. int var;
Question 47
Correct
a. const
b. final
c. abstract
d. static
Question 48
Correct
a. Charel Babbage
b. Blais Pascal
c. James Gosling
d. M. P Java
https://trimestralexam.amaesonline.com/2233/mod/quiz/review.php?attempt=49926&cmid=1690&showall=1 17/18
6/19/23, 8:47 AM PRELIM EXAM: Attempt review
Question 49
Correct
a. Virtual function
b. Inline function
c. Undefined functions
Question 50
Correct
In java control statements break, continue, return, try-catch-finally and assert belongs to?
a. Pause Statemen
b. Transfer statements
c. Selection statements
d. Loop Statements
◄ Announcements
Jump to...
https://trimestralexam.amaesonline.com/2233/mod/quiz/review.php?attempt=49926&cmid=1690&showall=1 18/18