OOP CPP KUK Solved Paper With Questions
OOP CPP KUK Solved Paper With Questions
COMPULSORY QUESTION
Data hiding is the concept of restricting access to the internal details of a class. It is implemented using access
The scope resolution operator (::) is used to define a function outside a class or to access a global variable when
Example:
class Sample {
int a;
public:
Sample(int x) { a = x; }
};
Exceptions are handled using try-catch blocks. Uncaught exceptions lead to program termination.
Example:
try { throw 10; } catch (int e) { cout << "Caught " << e; }
UNIT - I
Inline functions reduce the overhead of function calls by expanding the function at the point of its invocation.
Example:
A union allows storing different data types in the same memory location.
Example:
union Data {
int i;
float f;
};
Function overloading allows multiple functions with the same name but different parameters.
Example:
(ii) Pointer:
Example:
int x = 10;
int *p = &x;
UNIT - II
Object Oriented Programming using C++ - Solved Paper
4. What is the use of constructor and destructor in C++? How do we declare them? Write a program.
Example:
class Demo {
public:
};
Example:
class Complex {
int a, b;
public:
};
UNIT - III
Example:
class Shape {
};
Example:
Object Oriented Programming using C++ - Solved Paper
class A {};
Example:
class Sample {
int x;
public:
Sample(int a) { x = a; }
void operator++() { x = x + 1; }
};
UNIT - IV
8. What is the benefit of handling exceptions? How can you catch all exceptions? Explain with example.
Example:
try {
throw 10;
} catch (...) {
9. What do you mean by polymorphism? How can you achieve polymorphism with pointers? How late binding is different
Example:
class Base {
public:
Object Oriented Programming using C++ - Solved Paper
};
public:
};