TERM 3 OOP Prelim Lab Exam - Attempt Review

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 5

Home / My courses /

UGRD-CS6203-2113T /
Object-Oriented Programming /
Prelim Lab Exam

Started on Wednesday, 1 December 2021, 1:37 PM


State Finished
Completed on Wednesday, 1 December 2021, 1:38 PM
Time taken 1 min 16 secs
Marks 50.00/50.00
Grade 100.00 out of 100.00

Question 1
Correct

Mark 10.00 out of 10.00

What is the output of the following Java code?

class Person 

    private int age; 


    

    private Person() 
    { 

        age = 24; 

    } 

public class Test 


    public static void main(String[] args) 


    { 

        Person p = new Person(); 

        System.out.println(p.age); 
    } 

a. Syntax Error

b. Run Time Error

c. Compilation error

d. 24

Your answer is correct.


Question 2

Correct

Mark 10.00 out of 10.00

Find the correct answer from the following two program -  

a. The private
members can only be accessed using public

b. getter
and setter methods of super class are not shown in the example

c. The
derived class inherits all the members and methods 

d. The
private members can’t be accessed only in its own class

Your answer is correct.


Question 3

Correct

Mark 10.00 out of 10.00

Which among the following is correct for the


following code?
class A


    public : class B

    {
        public : B(int i):
data(i)

        {

        }
        int data;

    }
};

class C: public A
{

     class D:public A::B{ };

};

a. Multi-level inheritance is used, with nested classes

b. Single level inheritance is used, with both enclosing and nested classes

c. Single level inheritance is used, with nested classes

d. Multi-level inheritance is used, with nested classes

Your answer is correct.


Question 4

Correct

Mark 10.00 out of 10.00

Find the order of execution of constructors in Java Inheritance in the following bellow -

class Animal{
public Animal(){

System.out.println("Base Constructor");

}
}

class Cat extends Animal{


public Cat(){

System.out.println("Derived Constructor");
}

}
public class Program {

public static void main(String[] args) {

Cat c = new Cat();   


}

a. Base to derived class 

b. None

c. Random order

d. Derived to base class

Your answer is correct.


Question 5

Correct

Mark 10.00 out of 10.00

Check the program and find out if it will run properly?

class A 

 void msg() 

 { 
    System.out.println("Hello Java"); 

  } 

class B 

  void msg() 
  { 

     System.out.println("Welcome you"); 

  } 
 } 

class C extends A, B 

 public static void main(String args[]) 

 { 

   C obj = new C(); 

   obj.msg();//Now which msg() method would be called? 


  } 

 }

a. Got syntax error

b. Got compile time error


c. Was able to run properly

d. Displayed the final output

Your answer is correct.

◄ Prelim Lab Quiz 2

Jump to...

Midterm Lab Quiz 1 ►

You might also like