Professional Documents
Culture Documents
Term 3 OOP Prelim Lab Exam - Attempt Review1
Term 3 OOP Prelim Lab Exam - Attempt Review1
UGRD-CS6203-2113T /
Object-Oriented Programming /
Prelim Lab Exam
Question 1
Correct
{
public : class B
{
public : B(int i):
data(i)
{
}
int data;
}
};
class C: public A
{
class D:public A::B{ };
};
c. Single level inheritance is used, with both enclosing and nested classes
Find the correct answer from the following two program -
a.
The
private members can’t be accessed only in its own class
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 only be accessed using public
Question 3
Incorrect
{
void msg()
{
System.out.println("Hello Java");
}
}
class B
{
void msg()
{
System.out.println("Welcome you");
}
}
class C extends A, B
{
{
C obj = new C();
}
{
private int age;
private Person()
{
age = 24;
}
}
System.out.println(p.age);
}
b. Syntax Error
c. Compilation error
d. 24
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 {
a. None
b. Random order
Jump to...