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 Thursday, 4 November 2021, 9:52 PM


State Finished
Completed on Thursday, 4 November 2021, 10:25 PM
Time taken 32 mins 24 secs
Marks 40.00/50.00
Grade 80.00 out of 100.00

Question 1
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 nested classes

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

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

Your answer is correct.


Question 2
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. 24

b. Run Time Error

c. Compilation error

d. Syntax Error

Your answer is correct.


Question 3
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. Was able to run properly

b. Got compile time error


c. Displayed the final output

d. Got syntax error

Your answer is correct.


Question 4
Incorrect

Mark 0.00 out of 10.00

Find the correct answer from the following two program -  

a. The
derived class inherits all the members and methods

b. The private
members can only be accessed using public

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

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

Your answer is incorrect.

Question 5
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. Derived to base class

b. None

c. Base to derived class 

d. Random order

Your answer is correct.

◄ Prelim Lab Quiz 2

Jump to...

Midterm Lab Quiz 1 ►

You might also like