Professional Documents
Culture Documents
Term 3 OOP Prelim Lab Exam - Attempt Review2
Term 3 OOP Prelim Lab Exam - Attempt Review2
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{ };
};
d. Single level inheritance is used, with both enclosing and nested classes
{
private int age;
private Person()
{
age = 24;
}
}
System.out.println(p.age);
}
a. 24
c. Compilation error
d. Syntax Error
{
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();
}
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
Question 5
Correct
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 {
b. None
d. Random order
Jump to...