INDEX
S NO / TOPICS / PAGE NO1 / Unit 1 : Programming in C++ / 4- 55
2 / Unit 2 : Data Structures / 56-66
3 / Unit 3 : Database and SQL / 67-70
4 / Unit 4 : Boolean Logic / 71-75
5 / Unit 5 : Communication and Open Source Concepts / 76 -81
6 / Marking Scheme / 82-96
UNIT 1 : PROGRAMMING IN C++
OBJECT ORIENTED CONCEPTS (OOPS)
1. / The mechanism that binds code and data together and keeps them secure from outside world is known as- Abstraction
- Inheritance
- Encapsulation
- Polymorphism
2. / The term ______means the ability to take many forms.
- Abstraction
- Inheritance
- Encapsulation
- Polymorphism
3. / The members of a class by default are
- Public
- Protected
- Private
- Mandatory to specify
4. / It is possible to declare as a friend
- A member function
- A global function
- A class
- All of the above
5. / Which of the following statements is NOT valid about operator overloading?
- Only existing operators can be overloaded
- Overloaded operator must have at least one operand of its class type
- The overloaded operators follow the syntax rules of the original operator
- None of the above
6. / Polymorphism is implemented through ......
- Function Overlaoding
- Virtual Functions
- Operator Overloading
- All of these.
7. / An object is
- One instance of a class
- Another word for a class
- A class with static method
- A method that accesses class
8. / A class defined within another class is
- Nested class
- Inheritance
- Containership
- Encapsulation
9. / A blueprint of an object in C++ is called a
- Object
- Class
- Instance
- None of these
10. / At which point of time a variable comes into existence in memory is determined by its
- Scope
- Storage class
- Data type
- All of the above
11. / Which of the following is false for cin?
- It represents standard input
- It is an object of istream class.
- It is a class of which stream is an object
- Using cin the data can be read from user’s terminal
12. / Member functions, when defined within the class specification
- Are always inline
- Are not inline
- Are inline by default, unless they are too big or too complicated
- Are not inline by default.
13. / Access to private data
- Restricted to methods of the same class
- Restricted to methods of other classes
- Available to methods of the same class and other classes
- Not an issue because the program will not compile
14. / C++ was originally developed by
A.Clocksin and Melish
B.Donald E.Knuth
C.Sir Richard Hadlee
D.BjarneStroustrup
15. / Inheritance is done to
A.Implement real world.
B. Reusability
C. Both A &B.
D. None
16. / An instance of class is known as.....
- Entity
- Object
- Functions
- None
17. / Which can be passed as an argument to a function?
- Constant
- Expression
- Another function
- All of the above
18. / Act of representing essential features without including background details and explanations is known as ...
- Encapsulation
- Abstraction
- Inheritance
- Polymorphism
19. / Member of a class specified as ______are accessible only to method of the class.
- Private
- Public
- Protected
- Derive
20. / A class enforces data hiding through ...... and ...... members.
- Private
- Public
- Private and Protected
- Private and Public
21. / A struct is the same as a class except that
A.There are no member functions
B.All members are public
C.Cannot be used in inheritance hierarchy
D.It does have a this pointer
22. / Object is an identifiable ...... with some characteristics and behaviour.
- Class
- Instance
- Entity
- None
23. / A class which can use all the features of an established class,is
- A static class
- A super class
- A Super Class
- Overloaded
24. / The functions which are defined inside the class are known as ....
- Virtual Functions
- Static Functions
- Inline Functions
- None
25. / Which of the following cannot be legitimately passed to a function
- A constant
- A variable
- A structure
- A header file
26. / A function call mechanism that passes arguments to a function by passing a copy of the values of the arguments is ______
A.Call by name
B.Call by value
C.Call by reference
D.Call by value result
27. / A variable defined within a block is visible
A.From the point of definition onward in the program
B.From the point of definition onward in the function
C.From the point of definition onward in the block
D.Throughout the function
28. / The process of building new classes from existing one is called ______.
A.Polymorphism
B.Structure
C.Inheritance
D.Cascading
29. / What term is used to describe the internal representation of an object that is hidden from view outside the object's definition?
A.Polymorphism
B.Structure
C.Inheritance
D.Data Abstraction
30. / Which of the following concepts means wrapping up of data and functions together?
A.Polymorphism
B.Structure
C.Inheritance
D.Encapsulation
CLASS and OBJECT
1. / The members of a class, by default, are- public
- protected
- private
- mandatory to specify
2. / Which of the following statements are true in c++?
- Classes can not have data as public members.
- Structures can not have functions as members.
- Class members are private by default.
- None of these.
3. / Member functions, when defined within the class specification:
- are always inline.
- are not inline.
- are inline by default, unless they are too big or too complicated.
- are not inline by default.
4. / Which of the following concept of oops allows compiler to insert arguments in a function call if it is not specified?
- Call by value
- Call by reference
- Default arguments
- Call by pointer
5. / Which of the following term is used for a function declared inside a class?
- Member Variable
- Member function
- Class function
- Classic function
6. / Which of the following is an abstract data type?
A.intB.Double
C.stringD.Class
7. / Which of the following is correct about class and structure?
A. / class can have member functions while structure cannot.
B. / class data members are public by default while that of structure are private.
C. / Pointer to structure or classes cannot be declared.
D. / class data members are private by default while that of structure are public by default.
8. / Which of the following two entities (reading from Left to Right) can be connected by the dot operator?
A. / A class member and a class object.
B. / A class object and a class.
C. / A class and a member of that class.
D. / A class object and a member of that class.
9 / Which of the following keywords is used to control access to a class member?
A. / Default / B. / Break
C. / protected / D. / Asm
10. / Which of the following can access private data members or member functions of a class?
- Any function in the program.
- All global functions in the program.
- Any member function of that class.
- Only public member functions of that class.
11. /
Which of the following also known as an instance of a class?
A. / Friend Functions
B. / Object
C. / Member Functions
D. / Member Variables
12. /
Scope resolution operator is represented by
A. / ~
B. / ::
C. / :
D. / ;
13. / Constructor is executed when _____.
A. / an object is created
B. / an object is used
C. / a class is declared
D. / an object goes out of scope.
14. / Use of ______protects data from inadvertent modifications.
- private access specifier
- class protection operator, @
- none of these
- public access specifier
15. / Which of the following statements is correct?
A. / Data items in a class must be private.
B. / Both data and functions can be either private or public.
C. / Member functions of a class must be private.
D. / Constructor of a class cannot be private.
16. / Which of the following is the only technical difference between structures and classes in C++?
A. / Member function and data are by default protected in structures but private in classes.
B. / Member function and data are by default private in structures but public in classes.
C. / Member function and data are by default public in structures but private in classes.
D. / Member function and data are by default public in structures but protected in classes.
17. / Which of the following is user defined data type?
- int
- Private
- Class
- A & B Both
18. / The Object is not declared for which class?
- Parent
- Base
- Abstract
- Derived
19. / Data member is also called?
- Attribute
- Method
- Class
- Object
20. / A Class can have how many destructors?
- 1
- 2
- 3
- 4
21. / State true of false.
i) We cannot make the function inline by defining a function outside the class.
ii) A member function can be called by using its name inside another member function of the same class, this is known as nesting of member function.
A) True, True
B) True, False
C) False, True
D) False, False
22. / …………… is a way to bind the data and its associated functions together which allows the data and functions to be hidden.
A) Structure
B) Class
C) Enum
D) Both A and B
23. / What happens when we try to compile the class definition in following code snippet?
#include<iostream.h
void main()
{
class Birds {};
class Peacock : protected Birds {};
}
A. / It will not compile because class body of Eagle is not defined.
B. / It will not compile because a class cannot be protectedly inherited from other class.
C. / It will compile successfully.
D. / It will not compile because class body of Birds is not defined.
24. / Which of the following can access private data members or member functions of a class?
A. / Any function in the program.
B. / All global functions in the program.
C. / Any member function of that class.
D. / Only public member functions of that class.
25. / Which of the following type of data member can be shared by all instances of its class?
A. / Public
B. / Inherited
C. / protected
D. / Private
26. / How many specifiers are present in access specifiers in class?
A.1
B.2
C.3
D.4
27. / Which is used to define the member of a class externally?
A. :
B. ::
C. #
D. none of the above
28. / What is the output of this program?
#include <iostream.h
classrect
{
int x, y;
public:
voidval(int, int);
int area ()
{
return(x * y);
}
};
voidrect::val(int a, int b)
{
x = a;
y = b;
}
int main ()
{
rectrect;
rect.val(3, 4);
cout<"rect area: "<rect.area();
return0;
}
- rect area:12
- rect area: 12
- rect area:24
- rect area:42
29. / Which of the following is a valid class declaration?
A. class A { int x; };
B. class B { }
C. public class A { }
D. object A { int x; };
30. / When struct is used instead of the keyword class means, what will happen in the program?
A. access is public by default
- access is private by default
- access is protected by default
- none of the mentioned
31. / How to access the members through class object?
A. scope resolution operator
B. ternary operator
C. direct member access operator (.)
D. none of the mentioned
32. / Which of these following members are not accessed by using direct member access operator(.)?
A. public
B. private
C. protected
D. Both b & c
33. / What is the output of the following program?
#include <iostream.h
class Box
{
public:
double length;
double breadth;
double height;
};
void main()
{
Box Box1;
double volume;
Box1.height=5;
Box1.length=6;
Box1.breadth=7.1;
volume = Box1.height* Box1.length* Box1.breadth;
cout<"Volume of Box1 : "< volume <endl;
}
A. 210
B. 213
C. 215
D. 217
34. / What is the output of the program?
#include <iostream.h
classRect
{
int x, y;
public:
voidset_values(int,int);
int area ()
{
return(x * y);
}
};
voidRect::set_values(int a, int b){
x = a;
y = b;
}
int main ()
{
Rect recta, rectb;
recta.set_values(5, 6);
rectb.set_values(7, 6);
cout<"recta area: "<recta.area();
cout<"rectb area: "<rectb.area();
return0;
}
- recta area: 30 rectb area: 42
- recta area: 20 rectb area: 34
- recta area: 30 rectb area: 21
- none of the mentioned
35. / How many objects can created of a class?
- 1
- 2
- 3
- as many as possible
36. / Pick out the other definition of objects.
- member of the class
- associate of the class
- attribute of the class
- instance of the class
37. / What is the output of this program?
#include <iostream.h
class sample
{
private:
intvar;
public:
void input()
{
coutvar;
}
void output()
{
cout<"Variable entered is ";
coutvar<"\n";
}
};
void main()
{
sample object;
object.var=5;
object.input();
object.output();
}
- Variable entered is 5
- runtime error
- private member access by object
- none of the mentioned
38. / Which special character is used to mark the end of class?
A. ;
B. :
C. #
D. $
39. / What is the output of this program?
#include <iostream.h
class number
{
inti;
public:
intgeti();
voidputi(int j);
};
int number::geti()
{
returni;
}
void number::puti(int j)
{
i= j;
}
void main()
{
number s;
s.puti(10);
couts.geti();
}
- 10
- 11
- 20
- 22
40. / Which is true for this keyword
- this.member
- this->member
- this*.member
- *this.member
CONSTRUCTORS & DESTRUCTORS
1. / Which of the following is not a type of constructor?- Copy constructor
- Friend constructor
- Default constructor
- Parameterized constructor
2. / Which of the following statement is correct?
- A constructor is called at the time of declaration of an object.
- A constructor is called at the time of use of an object.
- A constructor is called at the time of declaration of a class.
- A constructor is called at the time of use of a class.
3. / Which of the following is correct about function overloading?
- The types of arguments are different.
- The order of argument is different.
- The number of argument is same.
- Both A and B.
4. / Given a class named Book, which of the following is not a valid constructor?
A.Book ( ) { }
B.Book ( Book b) { }
C.Book ( Book &b) { }
D.Book (char* author, char* title) { }
5. / How many constructors can a class have?
- 0
- 1
- 2
- any number
6. / Which of the following is not the characteristic of constructor.
- They should be declared in the public section.
- They do not have return type.
- They can not be inherited.
- They can’t be of same name as that of a class.
7. / A copy constructor takes
- no argument
- one argument
- two arguments
- arbitrary no. of arguments
8. / A constructor that accepts ______parameters is called the default constructor.
A. / one / B. / two
C. / no / D. / five
9. / What happens when a class with parameterized constructors and having no default constructor is used in a program and we create an object with no-arguments?
A. / Compile-time error.
B. / Preprocessing error.
C. / Runtime error.
D. / Runtime exception.
10. / Destructor has the same name as the constructor and it is preceded by ______.
A. / ! / B. / ?
C. / ~ / D.
11. / Constructors and destructors are called implicitly when the objects of the class is .....
A. / Created and releases memory
B. / inherit parent class
C. / are constructed
D. / are destroyed
12. / Which constructor function is designed to copy objects of the same class type?
A. / Create constructor
B. / Object constructor
C. / Dynamic constructor
D. / Copy constructor
13. / Which of the following statement is correct?
A. / Constructor has the same name as that of the class.
B. / Destructor has the same name as that of the class with a tilde symbol at the beginning.
C. / Both A and B.
D. / Destructor has the same name as the first member function of the class.
14. / Which of the following statement is incorrect?
A. / Constructor is a member function of the class.
B. / The compiler always provides a zero argument constructor.
C. / It is necessary that a constructor in a class should always be public.
D. / Both B and C.
15. / When are the Global objects destroyed?
A. / When the control comes out of the block in which they are being used.
B. / When the program terminates.
C. / When the control comes out of the function in which they are being used.
D. / As soon as local objects die.
16. / Copy constructor must receive its arguments by ______.
A. / either pass-by-value or pass-by-reference
B. / only pass-by-value
C. / only pass-by-reference
D. / only pass by address
17. / A function with the same name as the class, but preceded with a tilde character (~) is called ______of that class.
A. / constructor / B. / destructor
C. / function / D. / object
18. / Which of the following gets called when an object goes out of scope?
A. / constructor
B. / destructor
C. / main
D. / virtual function
19. /
Which of the following statement is correct?
A. / Destructor destroys only integer data members of the object.
B. / Destructor destroys only float data members of the object.
C. / Destructor destroys only pointer data members of the object.
D. / Destructor destroys the complete object.
20. / ______is used to make a copy of one object to another object of the same class type.
A. / constructor
B. / copy constructor
C. / destructor
D. / default constructor
21. / Constructors ______to create objects in different ways.
A. / cannot overloaded
B. / can be overloaded
C. / can be called
D. / can be nested
22. / Which of the following statement is correct?
A. / A destructor has the same name as the class in which it is present.
B. / A destructor has a different name than the class in which it is present.
C. / A destructor always returns an integer.
D. / A destructor can be overloaded.
23. / Which of the following are NOT provided by the compiler by default?
A. / Zero-argument Constructor
B. / Destructor
C. / Copy Constructor
D. / A & B
24. / It is a ______error to pass arguments to a destructor.
A. / logical / B. / virtual
C. / syntax / D. / linker
25. / If the programmer does not explicitly provide a destructor, then which of the following creates an empty destructor?
A. / Preprocessor
B. / Compiler
C. / Linker
D. / main()function
26. / A constructor having parameters with default values is known as ......
A. / default constructor
B. / copy constructor
C. / Constructor with default values.
D. / None of these
27. / How many default constructors per class are possible?
A. / Only one
B. / Two
C. / Three
D. / Unlimited
28. / Which of the following statement is correct about destructors?
A. / A destructor has void return type.
B. / A destructor has integer return type.
C. / A destructor has no return type.
D. / A destructors return type is always same as that of main().
29. / Which of the following statement is correct?
A. / A constructor has the same name as the class in which it is present.
B. / A constructor has a different name than the class in which it is present.
C. / A constructor always returns an integer.
D. / A constructor cannot be overloaded.
30. / Which of the following implicitly creates a default constructor when the programmer does not explicitly define at least one constructor for a class?
A. / Preprocessor / B. / Linker
C. / Loader / D. / Compiler
31. / A destructor takes ______arguments.
A. / one / B. / two
C. / three / D. / no
32. / Destructor calls are made in which order of the corresponding constructor calls?
A. / Reverse order
B. / Forward order
C. / Depends on how the object is constructed
D. / Depends on how many objects are constructed
33. / Which of the following never requires any arguments?
A. / Member function
B. / Friend function
C. / Default constructor
D. / constfunction
34. / A class's ______is called when an object is destroyed.
A. / constructor
B. / destructor
C. / assignment function
D. / copy constructor
35. / Destructors ______automatically when the program terminates with a call to function exit or function abort.
A. / are called
B. / are inherited
C. / are not called
D. / are created
36. / Which of the following statement is correct?
A. / A constructor of a derived class can access any public and protected member of the base class.
B. / Constructor cannot be inherited but the derived class can call them.
C. / A constructor of a derived class cannot access any public and protected member of the base class.
D. / Both A and B
37. / Which of the following statements are correct?
A. / Constructor is always called explicitly.
B. / Constructor is called either implicitly or explicitly, whereas destructor is always called implicitly.
C. / Destructor is always called explicitly.
D. / Constructor and destructor functions are not called at all as they are always inline.
38. / How many times a constructor is called in the life-time of an object?
A. / Only once
B. / Twice
C. / Thrice
D. / Depends on the way of creation of object
39. / Which of the following statement is correct about constructors?
A. / A constructor has a return type.
B. / A constructor cannot contain a function call.
C. / A constructor has no return type.
D. / A constructor has a void return type.
40. / Which of the following statement is correct whenever an object goes out of scope?
A. / The default constructor of the object is called.
B. / The parameterized destructor is called.
C. / The default destructor of the object is called.
D. / None of the above.
41. / Answer the questions (i) and (ii) after going through the following program
#include<iostream.h
#include<string.h
class Bazar
{
char Type[20];
char Product[20];
intQty;
float Price;
Bazar()//Function 1
{
strcpy (Type,”Electronic”);
strcpy (Product,”Calculator”);
Qty = 10;
Price=225;
}
public:
void Disp( )//Function 2
{
cout<Type<”-“<Product<”:“<Qty<”@“<Price<endl;
}
};
void main( )
{
Bazar B;//Statement 1
B.Disp();//Statement 2
}
(i)Will Statement 1 initialize all the data members for object B with the values given in the Function 1? Justify your answer suggesting the correction(s) to be made in the above code.
- Yes
- No
- Electronic-Calculator:10@225
- Electronic Calculator ::10@250
- Electronic Calculator :10@250
- Electronic-Calculator::10@225
42. / Answer the questions (i) and (ii) after going through the following class:
class Seminar
{
int Time;
public:
Seminar()//Function 1
{
Time=30;cout<”Seminar starts now”<end1;
}
void Lecture()//Function 2
{
cout<”Lectures in the seminar on”<end1;
}
Seminar(int Duration)//Function 3
{
Time=Duration;cout<”Seminar starts now”<end1;
}
~Seminar() //Function 4
{
cout<”Vote of thanks”<end1;
}
};
(i)In Object Oriented Programming, what is Function 4 referred as ?
- Copy Constructor
- Constructor
- Destructor
- Default Constructor
- When user calls it.
- It is invoked as soon as the scope of the object gets over.
- It can’be invoked.
- A & C
- Inheritance
- Encapsulation
- Constructor Overloading (Polymorphism)
- Data hiding
A.Seminar S1
B.Seminar S1;
C.S1;
D.A & C
(v)What is the correct code to call Function 3?
A. Seminar S2(90);
B.Seminar S2;
C.S2;
D.B & C
43. / In which case is it mandatory to provide a destructor in a class?
- Almost in every class
- Class for which two or more than two objects will be created
- Class for which copy constructor is defined
- Class whose objects will be created dynamically
44 / Constructor Overloading implements ...... feature of OOPs
- Polymorphism
- Inheritance
- Abstraction
- None
45 / What happens when following statements are executes assuming Book is a class
Book a,b;
------
a=b;
- Copy Constructor is called.
- Default Constructor
- Assignment Operation
- None
INHERITANCE