0% found this document useful (0 votes)
6 views4 pages

Oop - Exam Set A

An exam on object oriented programming

Uploaded by

emmajulienne63
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views4 pages

Oop - Exam Set A

An exam on object oriented programming

Uploaded by

emmajulienne63
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

FIRST SEMESTER EXAMINATION 2024/2025 ACADEMIC YEAR

DEPARTMENT: SOTWARE ENGINEERING DAY SESSION


COURSE TITLE: PROGRAMMING II
DURATION : 1 – 3PM - 2H DATE: 17 -02 – 25 CREDIT VALUE : 3
COURSE INSTRUCTOR: NGONG CONSTANTINE LEVEL: 200

SECTION A : MULTIPLE CHOICE QUESTIONS – 17 marks Answer all questions.


1. Which of the following is a feature of OOP?
A. Procedural programming C. Memory management
B. Abstraction D. Function pointers
2. What does a class in C++ represent?
A. emplate for objects C. A runtime variable
B. function definition D. A pointer
3. How do you create an object of a class in C++?
A. object = new Class(); C. Class->object;
B. Class object; D. object(Class);
4. What is the access specifier that allows members of a class to be accessible only within the
same class?
A. Public C. Protected
B. Private D. Static
5. What is the output of the following code?
class A {
public:
int x;
A() { x = 10; }
};
int main() {
A obj;
cout << obj.x;
}
A. 0 C. Compiler error
B. 10 D. Garbage value
6. Which of the following correctly implements inheritance in C++?
A. class A : inherits B C. class A -> B
B. class A : public B D. class A = new B
7. Which concept allows a derived class to use methods of its base class?
A. Polymorphism C. Inheritance
B. Encapsulation D. Abstraction
8. What is a constructor in C++?
A. A function used to destroy objects
B. A special function used to initialize objects
C. A function used to create pointers
D. A function used for overloading
9. What does the this pointer represent in C++?
A. The memory address of the base class
B. The current object of a class
C. A pointer to the destructor of the class
D. The global scope of the class
10. What is function overloading in C++?
A. Using multiple classes to define a function
B. Defining multiple functions with the same name but different arguments
C. Overriding a base class function in a derived class
D. Using a global function instead of a member function
11. What is polymorphism in C++?
A. Defining many classes in one file
B. The ability of a function to behave differently based on input types
C. A function with multiple arguments
D. Using global variables in functions
12. What type of function is called when an object is destroyed?
A. Constructor C. Virtual function
B. Destructor D. Inline function
13. Which of the following is not a type of inheritance in C++?
A. Single inheritance C. Multilevel inheritance
B. Multiple inheritance D. Object inheritance
14. What is the correct syntax to declare a friend function in C++?
A. friend void function(); C. void friend function();
B. friend: void function(); D. void function() friend;
15. What keyword is used to prevent a class from being inherited?
A. final C. protected
B. sealed D. private
16. What is the default access specifier for members of a class in C++?
A. Public
B. Private
C. Protected
D. None
17. What is an abstract class in C++?
A. A class with only private members
B. A class with no member functions
C. A class that cannot be instantiated and contains at least one pure virtual function
D. A class that can only have derived classes

SECTION B : STRUTURAL QUESTIONS. Answer all question : 28 marks


1. Define the following as seen in object oriented programming
a. Object
b. Classes
c. Methods 3 * 1 = 3 marks
2. What are the four major principles that make a language to be object oriented ? 4 marks
3. What are the difference between private and public class members ? 2 marks
4. What are the differences between data hiding and encapsulation ? 2 marks
5. What are the two major components of an object ? 2 marks
6. What is the relationship between a class and objects in that class ? 3 marks
7. What is a constructor ? Why are constructors used ? 2 marks
8. Evaluate the following using operator precedence in C++ to come out with the output.
#include<iostream>
using namesapce std ;
int main() {
int a = 20 ;
int b = 5 ;
int c = 15 ;
int d = 5 ;
int e ;
e = (a + b) * c/d ;
cout << « The Value of e (a + b) * c/d : » << e<<endl ;
e = ((a + b) * c)/d ;
cout << « The Value of e ((a + b) * c)/d : » << e<<endl ;
e = (a + b) *( c/d) ;
cout << « The Value of e (a + b) *( c/d) : » << e<<endl ;
e = a +( b * c)/d ;
cout << « The Value of e a +( b * c)/d : » << e<<endl ;
e=a&b;
cout << « The Value of e : » << e<<endl ;
e = a|b ;
cout << « The Value of e : » << e<<endl ;
e = a^1 ;
cout << « The Value of e : » << e<<endl ;
e = a>>1 ;
cout << « The Value of e : » << e<<endl ;
e = a>>1 ;
cout << « The Value of e : » << e<<endl ;
e = a<<1 ;
cout << « The Value of e : » << e<<endl ;

return 0 ;
}
10 marks

SECTIOB C : ESSAY – CASE STUDY 25 marks – Answer question 1 and Select any one
1. Write a program that reads the age of a person and categorizes them into one of the
following: 10 marks

"Child" (under 12)


"Teen" (13-19)
"Adult" (20-64)
"Senior" (65 and above)

SELECT ONE Question from this section


2. Design a class called Cube that has the following data member side of data type double.
Supply the following methods : a constructor with one argument, a getter and setter
method for the side of the cube, the volume equals to side raised to the power three.
Implement the class Cube and write a test class Cube Test in C++ to verify thhe
functionalities of the class Cube. 15 marks
OR
3. Define a class BankAccount with the following private attributes :
 Balance (double)
 accountNumber (string)
Provide the following public methods :
 deposit(double amount) – Adds the givien amount to the balance
 withdraw(double amount) – substracts the given amount from the balance
 getBalance() – Returns the current balance
In main(), create an object of BankAccount, deposit money, withdraw money and print the
balance. 15 marks

Good Luck

You might also like