Cs 201 Important Material For Viva Preparation
Cs 201 Important Material For Viva Preparation
Cs 201 Important Material For Viva Preparation
1. What is a program?
A program is a precise sequence of steps to solve a particular problem.
2. What is a class?
We write a C++ program using data members, and functions. We call this
program “class”.
3. What are data members?
The data members, functions and nested classes are called class members.
4. What is class layout?
The way in which data class members are arranged in a class object is called
class layout.
5. What is class template?
A template is used for generating class types.
6. What is comment in Programing language?
Comments are used to explain the functioning of the programs. It helps to
understand the code. C style of commenting is /*……..*/ also used in C++. And
new line oriented C++ style is //………
7. What is a constructor?
A constructor initializes the data member of an object in the scope. It has no
return type, and has the same name as class. We use many types of constructor by
overloading them.
Types of constructor:
Default constructor/compiler generated constructor
Simple constructor (takes no arguments)
Parameterized constructor (takes arguments)
Constructor overloading
Copy constructor
8. What is destructor?
A function called when a class object goes out of scope. It cleans up the object,
freeing resources like dynamic storage. The name of the destructor is the same as
that of a class with preceding tilde sign (~). It could not be overloaded. It has no
return type, and takes no argument.
Functions which don‟t return any value use keyword “void” instead of
return-data-type. The default data type of functions is int.
24.What is the calling methodology of a function?
The calling program just needs to write the function name and provide its
arguments without data types.
Declaration Definition
Int square (int) Int square(int number){
Return (number * number);
}