Objective Type Questions of Computer Science - XI-XII
Objective Type Questions of Computer Science - XI-XII
S NO TOPICS PAGE
NO
Source Concepts
1
UNIT 1 : PROGRAMMING IN C++
1. The mechanism that binds code and data together and keeps them
secure from outside world is known as
A. Abstraction
B. Inheritance
C. Encapsulation
D. Polymorphism
A. Abstraction
B. Inheritance
C. Encapsulation
D. Polymorphism
A. Public
B. Protected
C. Private
D. Mandatory to specify
A. A member function
B. A global function
C. A class
D. All of the above
2
type
C. The overloaded operators follow the syntax rules of the original
operator
D. None of the above
A. Function Overlaoding
B. Virtual Functions
C. Operator Overloading
D. All of these.
7. An object is
A. Nested class
B. Inheritance
C. Containership
D. Encapsulation
9. A blueprint of an object in C++ is called a
A. Object
B. Class
C. Instance
D. None of these
A. Scope
B. Storage class
C. Data type
D. All of the above
3
C. It is a class of which stream is an object
D. Using cin the data can be read from user’s terminal
A. Entity
B. Object
C. Functions
D. None
A. Constant
B. Expression
C. Another function
D. All of the above
4
18. Act of representing essential features without including background
details and explanations is known as ...
A. Encapsulation
B. Abstraction
C. Inheritance
D. Polymorphism
A. Private
B. Public
C. Protected
D. Derive
A. Private
B. Public
C. Private and Protected
D. Private and Public
A. Class
B. Instance
C. Entity
D. None
23. A class which can use all the features of an established class,is
A. A static class
B. A super class
C. A Super Class
5
D. Overloaded
24. The functions which are defined inside the class are known as ....
A. Virtual Functions
B. Static Functions
C. Inline Functions
D. None
A. A constant
B. A variable
C. A structure
D. A header file
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
28. The process of building new classes from existing one is called
______.
A. Polymorphism
B. Structure
C. Inheritance
D. Cascading
6
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
7
CLASS and OBJECT
1. The members of a class, by default, are
A. public
B. protected
C. private
D. mandatory to specify
2. Which of the following statements are true in c++?
A. Classes can not have data as public members.
B. Structures can not have functions as members.
C. Class members are private by default.
D. None of these.
3. Member functions, when defined within the class specification:
A. are always inline.
B. are not inline.
C. are inline by default, unless they are too big or too complicated.
D. 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?
A. Call by value
B. Call by reference
C. Default arguments
D. Call by pointer
5. Which of the following term is used for a function declared inside a class?
A. Member Variable
B. Member function
C. Class function
D. Classic function
A. int B. Double
C. string D. Class
8
7. Which of the following is correct about class and structure?
A. class can have member functions while structure cannot.
class data members are public by default while that of structure are
B.
private.
class data members are private by default while that of structure are
D.
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.
C. protected D. Asm
10. 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.
11. Which of the following also known as an instance of a class?
A. Friend Functions
B.
Object
C.
Member Functions
D.
Member Variables
9
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
Member function and data are by default private in structures but public
B.
in classes.
Member function and data are by default public in structures but private
C.
in classes.
10
A. int
B. Private
C. Class
D. A & B Both
18. The Object is not declared for which class?
A. Parent
B. Base
C. Abstract
D. Derived
19. Data member is also called?
A. Attribute
B. Method
C. Class
D. Object
20. A Class can have how many destructors?
A. 1
B. 2
C. 3
D. 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?
11
#include<iostream.h>
void main()
{
class Birds {};
class Peacock : protected Birds {};
}
24. Which of the following can access private data members or member functions of a
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
Private
D.
12
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;
}
A. rect area:12
B. rect area: 12
C. rect area:24
D. rect area:42
13
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
B. access is private by default
C. access is protected by default
D. 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
14
B. 213
C. 215
D. 217
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;
}
15
36. Pick out the other definition of objects.
A. member of the class
B. associate of the class
C. attribute of the class
D. instance of the class
37. What is the output of this program?
#include <iostream.h>
class sample
{
private:
intvar;
public:
void input()
{
cout<<var;
}
void output()
{
cout<<"Variable entered is ";
cout<<var<<"\n";
}
};
void main()
{
sample object;
object.var=5;
object.input();
object.output();
}
A. Variable entered is 5
B. runtime error
C. private member access by object
D. none of the mentioned
16
#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);
cout<<s.geti();
}
A. 10
B. 11
C. 20
D. 22
40. Which is true for this keyword
A. this.member
B. this->member
C. this*.member
D. *this.member
17
CONSTRUCTORS & DESTRUCTORS
1. Which of the following is not a type of constructor?
A. Copy constructor
B. Friend constructor
C. Default constructor
D. Parameterized constructor
B. Book ( Book b) { }
B. 1
C. 2
D. any number
18
7. A copy constructor takes
A. no argument
B. one argument
C. two arguments
A. one B. two
C. no D. five
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 .....
C. are constructed
D. are destroyed
19
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
Destructor has the same name as that of the class with a tilde
B.
symbol at the beginning.
C. Both A and B.
D. Both B and C.
When the control comes out of the block in which they are being
A.
used.
When the control comes out of the function in which they are
C.
being used.
20
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
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. constructor
B. copy constructor
C. destructor
D. default constructor
21
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 destructor has the same name as the class in which it is
A.
present.
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
22
A. default constructor
B. copy constructor
D. None of these
A. Only one
B. Two
C. Three
D. Unlimited
30. Which of the following implicitly creates a default constructor when the
programmer does not explicitly define at least one constructor for a class?
23
A. Preprocessor B. Linker
C. Loader D. Compiler
E.
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
A. Member function
B. Friend function
C. Default constructor
D. const function
A. constructor
B. destructor
C. assignment function
copy constructor
D.
24
A. are called
B. are inherited
D. are created
36. Which of the following statement is correct?
D. Both A and B
A. Only once
B. Twice
C. Thrice
25
A. A constructor has a return type.
#include<iostream.h>
#include<string.h>
class Bazar
{
char Type[20];
char Product[20];
int Qty;
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( )
26
{
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.
A. Yes
B. No
(ii) What shall be the possible output when the program gets
executed? (Assuming, if required – the suggested correction(s)
are made in the program).
A. Electronic-Calculator:10@225
B. Electronic Calculator ::10@250
C. Electronic Calculator :10@250
D. 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
27
{
cout<<”Vote of thanks”<<end1;
}
};
A. Copy Constructor
B. Constructor
C. Destructor
D. Default Constructor
C. It can’be invoked.
D. A & C
A. Inheritance
B. Encapsulation
C. Constructor Overloading (Polymorphism)
D. Data hiding
28
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?
A. Almost in every class
B. Class for which two or more than two objects will be created
29
INHERITANCE
1. The process of building new classes from existing one is called ______.
E. Polymorphism
F. Structure
G. Inheritance
H. Cascading
A. Polymorphism
B. Single Inheritance
C. Multilevel Inheritance
D. Message Passing
3. If a class C is derived from class B, which is derived from class A, all through
public inheritance, then a class C member function can access
A. Private
B. Public
C. Protected
D. All of the above
A. Child class
B. Subclass
C. Derived class
D. Parent class
30
IV. A friend function can be called like a normal function.
V. Nested class is a derived class.
A. I, II, III
B. II, III, V
C. III, IV, V
D. I, II, IV
7. In multiple inheritance -
8. When a sub class is inherited from only one super class .It is known as
A. Single inheritance
B. Multiple inheritance
C. Hierarchical inheritance
D. Multilevel inheritance
A. Private
B. Public
C. Protected
D. All of the above
11. In a student grading system, objects from different classes communicate with
each other. These communications are known as _____.
A. Inheritance
B. Scalability
C. Encapsulation
D. Polymorphism
31
12. What common technique attempts to save time and energy by reducing redundant
work in object-oriented programming?
A. Reduce lines of programming
B. Reuse of code
C. Reduce size of systems being developed
D. Merging different systems together
13. Which of the following term is used for a function defined inside a class?
A. Member Variable
B. Member function
C. Class function
D. Classic function
14. Which of the following is the valid class declaration header for the derived class b
with base class a and derived class c with base class b?
32
17. The major goal of inheritance in c++ is:
A. To facilitate the conversion of data types.
B. To help modular programming.
C. To extend the capabilities of a class.
D. To hide the details of base class.
18. Consider the following class definitions:
class a
{
};
class b: protected a
{
};
What happens when we try to compile this class?
A. Will not compile because class body of a is not defined.
B. Will not compile because class body of b is not defined.
C. Will not compile because class a is not public inherited.
D. Will compile successfully.
19. In access control in a protected derivation, visibility modes will change as follows:
A. private, public and protected become protected
B. only public becomes protected.
C. public and protected become protected.
D. only private becomes protected.
20. Which allows you to create a derived class that inherits properties from more than
one base class?
A. Multilevel inheritance
B. Multiple inheritance
C. Hybrid Inheritance
D. Hierarchical Inheritance
21. Which feature in OOP allows reusing code?
A. Polymorphism
B. Inheritance
C. Encapsulation
D. Data hiding
22. To hide a data member from the program, you must declare the data member in the
_____ section of the class
A. concealed
B. confidential
C. hidden
D. private
33
23. When you derive a class privately, a protected base class member becomes
A. private
B. public
C. not inherited
D. protected
24. Irrespective of type of derivation__________members of a base class are
never accessible in derived class.
27.
Which type of inheritance is depicted in the given example?
class school : public student, private teacher
A. Multilevel Inheritance
B. Multiple Inheritance
C. Single Level Inheritance
D. None of these
28. When derived class and base classes both contain constructors, the base
constructor is executed first and then the constructor in the derived class is
executed.
A. True
B. False
C. All of the above
D. None of the above
34
29. How Many bytes will be required by an object of the class SHOP?
class CUSTOMER
{
intCust_no;
char Cust_Name[20];
};
class SALESMAN
{
intSalesman_no;
char Salesman_Name[20];
protected:
float Salary;
};
class SHOP : private CUSTOMER, public SALESMAN
{
char Voucher_No[10];
char Sales_Date[8];
};
A. 56 bytes
B. 18 bytes
C. 88 bytes
D. 66 bytes
30. Which type of inheritance is shown in the following example?
class olympics
{
int no_of_events; char country_name[25];
};
class outdoorgame : public olympics
{
char eventname[20];
inteventcode;
};
class hockey : public outdoorgame
{
intno_of_players;
char venue[25];
};
A. Multilevel Inheritance
B. Multiple Inheritance
C. Single Level Inheritance
35
D. None of these
31. consider the following class declaration and answer the question below :
class university {
intnoc;
protected;
char uname[25];
public:
university();
char state[25];
};
int nod;
char cname[25];
public:
college();
};
char dname[25];
intnof;
public:
department();
};
A. university
B. department
C. college
36
32. consider the following class declaration and answer the question below :
class university {
int noc;
protected;
char uname[25];
public:
university();
char state[25];
};
int nod;
char cname[25];
public:
college();
};
char dname[25];
intnof;
public:
department();
};
(i) How many bytes does an object belonging to class college, university
A. 79, 52,106
B. 52,106,79
C. 106,79,52
D. 79,54,106
37
(ii) Which data member will be accessible from the object of class
department?
A. noc
B. dname
C. nof
D. state
38
return0;
}
A. 54.3R
B. R4.35
C. 4.3R5
classBaseClass
{
protected:
inti;
public:
BaseClass(int x)
{
i= x;
}
~BaseClass()
{
}
};
classDerivedClass:publicBaseClass
{
int j;
public:
DerivedClass(int x, int y):BaseClass(y)
{
j = x;
}
~DerivedClass()
{
}
void show()
{
cout<<i<<" "<< j <<endl;
}
};
39
int main()
{
DerivedClassob(3, 4);
ob.show();
return0;
}
A. 3 4
B. 4 3
C. 4
D. 3
class Base
{
public:
int m;
Base(int n=0)
: m(n)
{
cout<<"Base"<<endl;
}
};
class Derived:public Base
{
public:
double d;
Derived(double de =0.0)
: d(de)
{
cout<<"Derived"<<endl;
}
};
int main()
{
cout<<"Instantiating Base"<<endl;
Base cBase;
cout<<"Instantiating Derived"<<endl;
Derived cDerived;
return0;
40
}
A. Instantiating Base
Base
Instantiating Derived
Base
Derived
B. Instantiating Base
Instantiating Derived
Base
Derived
C. Instantiating Base
Base
Instantiating Derived
Base
36.
What is the output of this program?
#include <iostream.h>
class Parent
{
public:
Parent (void)
{
cout<<"Parent()\n";
}
Parent (inti)
{
cout<<"Parent("<<i<<")\n";
};
Parent (void)
{
cout<<"~Parent()\n";
};
};
41
class Child1 :public Parent {};
class Child2 :public Parent
{
public:
Child2 (void)
{
cout<<"Child2()\n";
}
Child2 (inti): Parent (i)
{
cout<<"Child2("<<i<<")\n";
}
~Child2 (void)
{
cout<<"~Child2()\n";
}
};
int main (void)
{
Child1 a;
Child2 b;
Child2 c(42);
return0;
}
A. Parent()
Parent()
Child2()
Parent(42)
Child2(42)
~Child2()
~Parent()
~Child2()
~Parent()
~Parent()
42
Data File Handling
Q1 Which enables a program to store the data permanently on secondary
storage devices
(a) monitor (b) printer
(c) file (d ) None of these
Q2 A collection of related data stored on some storage devices such as a
hard disk, magnetic tape or floppy disk.
(a) program (b) process
(c) file (d ) None of these
Q3 Data files can be classified as
(a) Text File (b) Binary File
(c) Both (a) & (b) (d ) None of these
Q4 The files that store data in the form of binary digits are known as
(a) Text File (b) Binary File
(c) Both (a) & (b) (d ) None of these
Q5 The files that store data as strings of characters are known as
(a) Text File (b) Binary File
(c) Both (a) & (b) (d ) None of these
Q6 A flow of data in the form of a sequence of bytes is known as
The files that store data in the form of binary digits are known as
(a) word (b) string
(c) stream (d ) None of these
Q7 The stream that reads the data from the device and supplies it to the
program is known as
(a) input stream (b) output stream
(c) Both (a) & (b) (d ) None of these
Q8 The stream that receives data from the program and writes it to the
device is known as
(a) input stream (b) output stream
(c) Both (a) & (b) (d ) None of these
Q9 Which one is file input stream class
(a) ifstream (b) ofstream
(c) both (a) & (b) (d ) None of these
43
Q12 A file can be opened by
(a) constructor (b) open( )
(c) both (a) & (b) (d ) None of these
Q13 Two or more file modes can be combined using the operator
(a) bitwise OR (|) (b) bitwise AND ( &)
(c) both (a) & (b) (d ) None of these
Q14 The default mode for the ifstream class is
(a) ios::in (b) ios::out
(c) both (a) & (b) (d ) None of these
Q15 The default mode for the ifstream class is
(a) ios::in (b) ios::out
(c) both (a) & (b) (d ) None of these
Q16 By default all files are open in which mode
(a) text mode (b) binary
(c) both (a) & (b) (d ) None of these
Q17 The open in which mode is compulsory to close the file by close( ) method
(a) constructor (b) open( )
(c) both (a) & (b) (d ) None of these
Q18 Which method is used to read the data from a file
(a) get( ) (b) read( )
(c) both (a) & (b) (d ) None of these
Q19 Which method is used to write the data to the file
(a) put( ) (b) write( )
(c) both (a) & (b) (d ) None of these
Q20 The current position of a get pointer can be known by using
(a) tellg( ) (b) tellp( )
(c) seekg( ) (d ) seekp( )
Q21 The current position of a put pointer can be known by using
(a) tellg( ) (b) tellp( )
(c) seekg( ) (d ) seekp( )
Q22 Which of these stream classes can be used to read data from a file?
(a) fstream (b) ifstream
( c) ofstream (d ) both (a) & (b)
Q23 Which of these file modes allows to write data anywhere in a file?
(a) ios::ate (b) ios::app
(c) ios::out (d ) ios::trunk
Q24 Which of these functions allows to change the position of the get
pointer?
(a) tellg( ) (b) tellp( )
44
(c) seekg( ) (d ) seekp( )
Q25 Which of these refers to the end position of a file?
(a) ios::beg (b) ios::end
(c) ios::cur (d ) None of these
Q26 Which of these functions returns a non-zero value if end of file is
encountered while reading data from a file ?
(a) eof( ) (b) fail( )
(c) bad( ) (d ) good( )
45
POINTERS
1. Which of the following is the proper declaration of a pointer?
A. int x;
B. int &x;
C. ptr x;
D. int *x;
A. first letter
B. entire string
C. it is a syntax error
D. last letter
46
}
A. a
B. b
C. c
D. d
6. Which of the following declarations are illegal?
A. void *ptr;
B. char *str = “hello”;
C. char str = “hello”;
D. const *int p1;
7. You have assigned the address of Value to the pointer P, Which statement
will display the value stored in Value?
A. cout<<P;
B. cout<<*Value;
C. cout<<&P;
D. cout<<*<P;
8. A pointer to a block of memory is effectively same as an array
A. True
B. False
9. Which of the following gives the value stored at the address pointed to by
pointer a?
A. a;
B. val(a);
C. *a;
D. &a;
10. Which of the following gives the memory address of a pointer a?
A. a;
B. *a;
C. &a;
D. address(a);
int *p1,*p2;
p1=new int;
p2=new int;
*p1=10;
*p2=20;
cout<<*p1<< " "<<*p2<<endl;
*p1=*p2;
47
cout<<*p1<< " "<<*p2<<endl;
*p1=30;
cout<<*p1<< " "<<*p2<<endl;
A. 10 20
20 20
30 20
B. 10 20
20 40
30 40
C. 20 20
20 30
20 20
D. None
12. The operator used for dereferencing or indirection is ____
A. *
B. &
C. ->
D. –>>
13. Which of the following is illegal?
A. int *ip;
B. string s, *sp = 0;
C. int i; double* dp = &i;
D. int *pi = 0;
14. What will happen in this code?
int a = 100, b = 200;
int *p = &a, *q = &b;
p = q;
A. b is assigned to a
B. p now points to b
C. a is assigned to b
D. q now points to a
#include <iostream.h>
void main()
{
int a = 5, b = 10, c = 15;
int *arr[ ] = {&a, &b, &c};
48
cout << arr[1];
}
A. 5
B. 10
C. 15
D. it will return some random address value
A. ABCDEFGHIJ
B. AAAAAAAAAA
C. JJJJJJJJ
D. none of the mentioned
Each time we are assigning 65 + i. In first iteration i = 0 and 65 is assigned.
So it will print from A to J.
17. What is the output of this program?
#include <iostream.h>
int main()
{
char *ptr;
char Str[] = "abcdefg";
ptr = Str;
ptr += 5;
cout << ptr;
return 0;
}
A. fg
B. cdef
C. defg
49
D. abcd
18. What is the output of this program?
#include <iostream.h>
void main()
{
int a[2][4] = {3, 6, 9, 12, 15, 18, 21, 24};
cout << *(a[1] + 2) << *(*(a + 1) + 2) << 2[1[a]];
}
A. 15 18 21
B. 21 21 21
C. 24 24 24
D. Compile time error
Explanation:a[1][2] means
50
cout << *p;
}
A.
4
B.
5
C.
6
D.
7
View Answer
Answer:b
Explanation:In this program, we are making the pointer point to next value
and printing it.
#include <iostream.h>
void main ()
{
int numbers[5];
int * p;
p = numbers; *p = 10;
p++; *p = 20;
p = &numbers[2]; *p = 30;
p = numbers + 3; *p = 40;
p = numbers; *(p + 4) = 50;
for (int n = 0; n < 5; n++)
cout << numbers[n] << ",";
51
}
A. 10, 20, 30, 40, 50
B. 1020304050
C. compile error
D. runtime error
Explanation:In this program, we are just assigning a value to the array and
printing it and immediatly dereferencing it.
#include <iostream.h>
int main()
{
int arr[] = {4, 5, 6, 7};
int *p = (arr + 1);
cout << *arr + 9;
}
A. 12
B. 5
C. 13
D. error
Explantion:In this program, we are adding the value 9 to the initial value of
the array, So it’s printing as 13.
#include<iostream.h>
void main()
{
int arr[] = {12, 23, 34, 45};
int *ptr = arr;
int val = *ptr; cout << val << endl;
val = (*ptr)++; cout << val << endl; // first print value then increment (post
increment in value)
val = *ptr; cout << val << endl; // only values are changing
val = *++ptr; cout << val << endl; // first increment the address and then
print the value.
}
52
A. 12 B. 12 C. 12 D. 12
12 12 13 12
13 14 13 13
22 23 23 23
#include<iostream.h>
void main()
{
int arr[] = {12, 23, 34, 45};
int *ptr = arr;
int val = *ptr; cout << val << endl;
val = *ptr++; cout << val << endl; //increment in address
val = *ptr; cout << val << endl;
val = *++ptr; cout << val << endl;
}
A. 12 B. 12 C. 12 D. 12
12 12 12 22
13 23 23 23
22 34 23 23
26. #include<iostream.h>
void main()
{
int arr[] = {12, 23, 34, 45};
int *ptr = arr;
int val = *ptr; cout << val << endl;
val = *ptr++; cout << val << endl;
val = *ptr; cout << val << endl;
val = ++*ptr; cout << val << endl;
}
A. 12 B. 12 C. 12 D. 22
12 12 12 22
12 23 23 23
22 24 23 23
53
UNIT 2: DATA STRUCTURES
ARRAYS
1 Which of the following correctly declares an arrayanarray?
A. int anarray[10];
B. int anarray;
C. an array{10};
D. array anarray[10];
5. What is an array?
a) An array is a series of elements of the same type in contiguous memory
locations
b) An array is a series of element
c) An array is a series of elements of the same type placed in non-
contiguous memory locations
d) None of the mentioned
6. Which of the following gives the memory address of the first element in
array?
a) array[0];
54
b) array[1];
c) array(2);
d) array;
7. What is the formula for address calculation in row major order of
element A[I][J] of an array A [r][c] if B is the Base address, W is the
word size, r is number of rows, c is number of columns.
10. What is the formula for address calculation in column major order of
element A[I][J] of an array A [Lr…..Ur][Lc…..Uc] if B is the Base address,
W is the word size, r is number of rows, c is number of columns.
55
C. Address of element A[I][J] = B+W[I-Lr)+ c*( (J-Lc)]
11. P is 2-D array [10x5]. Each element of the array is stored in 2 memory
locations. If X[1,1] begins at address 180, find the correct location of
P[2,4]. The arrangement is in row-major.
A. 176
B. 190
C. 196
D. 208
12. A character array A[-20..20],10…35] is stored in memory along with
columns. The beginning address is 500 the identify the location of
A[0,40].
A. 1234
B. 1340
C. 2345
D. 3245
13. An array P[20][30] is stored in the memory along the column with each of
the element occupying 4 bytes, find out the Base Address of the array, if
an element P[2][20] is stored at the memory location 5000.
A. 3454
B. 3390
C. 3392
D. 6545
14. If an Array B[11][8] is stored as column wise and B[2][2] is stored at
1036 and B[3][3] at 1084, write the addresses of B[5][3] and B[1][1].
15. An array Arr [50][100] is stored in the memory along the row with each
element occupying 2 bytes.Find out the address of the location
Arr[20][50],if the location Arr[10][25] is stored at the address 10000.
56
Base address is …………………….
17. Write a function in C++ which an accepts an integer array and its size as
argument/ parameters and exchanges the values of first half side
elements with the second half side elements of the array.
Example: If an array of eight elements has initial content as
2,4,1,6,7,9,23,10,16
The function should rearrange the array as
9,23,10,16,2,4,1,6,7
18. The function definition is given below:
void exchange(int a[ ], int n)
{
inti, mid, j, temp;
mid=n/2; //divide total no .of elements by 2 and assign the result to
mid
if (n%2= = 0)
j=mid;
else
j=mid+1;
//swap elements
for(i=0; i<mid; i++, j++)
{
temp = a[i];
a[i] = a[j];
a[j] = temp;
}
}
19. Write a function in C++ to print the sum of all the values which are either
divisible by 3 or are divisible by 5 present in a two dimensional array
passed as the argument to the function.
20. Define a function SwapArray(int [ ] , int) that would accept a one
dimensional integer array NUMBERS and its size N. The function should
rearrange the array in such a way that the values of alternate locations
of the array are exchanged ( Assumed the size of the array to be even)
Example:
If the array initially contains
[2,5,9,14,17,8,19,16]
57
then after rearrangement the array should contain
[5,2,14,9,8,17,16,19]
Ans void SwapArray(int NUMBERS[ ], int N)
{
inti, temp ;
for ( i =0 ; i<N; i +=2)
{
temp=NUMBERS[i] ;
NUMBERS[i] = NUMBERS[i+1];
NUMBERS[i+1] = temp;
}
}
21. Write a function in C++ which accepts a character array and its size as
arguments and reverse that array without using second array and library
function.
Example : if the array is having
“Computer Science”
Then after reversal it should rearranged as
“ecneicSretupmoC”
22. The function definition is given below:
void Reversearray(int a[ ], int size)
{
int temp, i, j;
for(inti = 0, j=size-1;i<j; i++,j--)
{
temp = a[i];
a[i] = a[j];
a[j] = temp;
}
}
58
float marks;
};
59
{
if( E [ j ] . salary > highest )
{
highest=E [j].salary;
pos = j;
}
}
temp=E[i] ;
E[i]=E[pos];
E[pos]=temp;
}
}
Ans: Write a function in C++ to merge the contents of two sorted arrays A and
B, into the third array C. Assume array A is sorted in ascending order, B
is sorted in descending order, the resultant array is required to be in
ascending.
25. Write a function in C++ to merge the contents of two sorted arrays A and
B, into the third array C. Assume array A is sorted in descending order, B
is sorted in descending order, the resultant array is required to be in
ascending.
Ans: Write a function in C++ to merge the contents of two sorted arrays A and
B, into the third array C. Assume array A is sorted in ascending order, B
is sorted in ascending order, the resultant array is required to be in
descending.
26. Write a function in C++ to merge the contents of two sorted arrays A and
B, into the third array C. Assume array A is sorted in ascending order, B
is sorted in ascending order, the resultant array is required to be in
ascending.
27. Write a function in C++ to merge the contents of two sorted arrays A and
B, into the third array C. Assume array A is sorted in descending order, B
is sorted in descending order, the resultant array is required to be in
descending.
60
STACK, QUEUE AND LINKED LIST
1. Linked list is a collection of : -
A. Data elements, called nodes pointing to the next nodes by means of
pointers.
B. Data elements, called nodes pointing to the next nodes by means of
integers
C. Data elements, called nodes
D. B & C
2. A stack is a linear list implemented in
A. LIFO
B. FIFO
C. SIFO
D. FISO
3. A queue is a linear list implemented in
A. LIFO
B. FIFO
C. SIFO
D. FISO
4. Which memory allocation technique reserves fixed amount of memory
before actual processing takes place?
A. Dynamic memory allocation
B. Static memory allocation
C. Root memory allocation
D. None of them
5. Which memory allocation technique allocates an amount of memory during
program run?
A. Dynamic memory allocation
B. Static memory allocation
C. Root memory allocation
D. None of them
6. Which data structure works on static memory allocation?
A. Linked List
B. Trees
61
C. Stack
D. Array
7. Which data structure works on dynamic memory allocation?
A. Linked List
B. Structures
C. Array
D. Pointer
8. Write the full form of FIFO and LIFO.
FIFO………………………………………
LIFO…………………………….
9. An insertion operation in a stack is called: -
A. POP
B. PUSH
C. Force
D. None of them
10. A delete operation in a stack is called: -
A. POP
B. PUSH
C. Force
D. None of them
11. Identify the name of the pointer generally used to implement stack
A. Rear
B. Front
C. Top
D. B&C
12. Identify the name of the pointer generally used to insert new element in a
queue
A. Rear
B. Front
C. Top
D. B&C
13. Identify the name of the pointer generally used to delete an existing
element from a queue
A. Rear
B. Front
C. Top
D. B&C
62
14. What is underflow in an array/stack/queue?
A. If one tries to delete an element from an empty array/stack/queue.
B. If one tries to delete an element from a partially empty
array/stack/queue.
C. If one tries to insert an element into an empty array/stack/queue.
D. B & C
63
D. a AND NOT b OR c NOT NOT
19. Find the Correct choice after calculating following postfix notation.
100,40,+,20,14,-,8,*,+
A. 198
B. 188
C. 78
D. None of them
64
UNIT 3: DATABASES MANAGEMENT SYSTEM
AND SQL
1 The collection of related data from which users can efficiently retrieve
the desired information is known as
(a) Database (b) Table
(c) Relation (c) DBMS
2 The software that allows the user to access the data contained in a
database is known are
(a) Database (b) Table
(c ) Relation (d) DBMS
3 The advantages of DBMS are
(a) Data redundancy (b) Data Security
(c ) Data integrity (d) All of the above
4 A ....... holds one piece of information about an item or subject in the
database.
(a) Record (b) field
(c ) domain (d) None of these
5 A ....... is a collection of multiple related fields that can be treated as a
unit.
(a) Record (b) field
(c ) domain (d) None of these
6 The ................ data model was developed by E F Codd of IBM in 1970.
(a) Relational (b) Network
(c ) Hierarchical (d) None of these
7 Name the data model in which all the tables are linked with each other
using a common attribute in the tables.
(a) Relational (b) Network
(c ) Hierarchical (d) None of these
8 In relational data model , collection of logically records are known as
(a) Relation (b) Table
(c ) Both (a) & (b) (d) None of these
9 The rows of a relation are referred to
(a) tuples (b) attributes
(c ) domain (d) None of these
10 The columns of a relation are referred to
(a) tuples (b) attributes
(c ) domain (d) None of these
11 The set of permissible values of the same type for a column is known as
(a) tuples (b) attributes
65
(c ) domain (d) None of these
66
23 The operation that displays the third relation that includes all the tuples
from the first relation combined with every tuple of the second relation.
(a) SET DIFFERENCE (b) PROJECT
(c ) CARTESIAN PRODUCT (d) INTERSECTION
24 Standard language for RDBMS is
(a) SQL (b) PASCAL
(c ) JAVA (d) C++
25 Oracle, Sybase, Microsoft SQL Server, Access, Ingres etc are the
example of
(a) Programming Language (b) RDBMS
(c ) Computer Hardware (d) OOPS
26 In SQL, the commands that are used to create, manipulate and delete a
database and its objects are known as
(a) DDL (b) DML
(c ) DCL (d) None of these
27 In SQL, the commands that are used to manipulate the data in the table
are known as
(a) DDL (b) DML
(c ) DCL (d) None of these
28 In SQL, the commands that are used to grant or revoke access rights to
the database users are known as
(a) DDL (b) DML
(c ) DCL (d) None of these
29 A condition or a check that is applicable to an attribute or a set of
attributes in a table is known as
(a) constraint (b) constant
(c ) variable (d) None of these
30 The constraint that ensures that no two rows are identical
(a) NOT NULL (b) DEFAULT
(c ) UNIQUE (d) None of these
31 The constraint that doesn’t allow NULL values in a specified column.
(a) NOT NULL (b) DEFAULT
(c ) UNIQUE (d) None of these
32 The keyword that is used to display the results of the SELECT command
after eliminating the duplicate rows
(a) ALL (b) DISTINCT
(c ) UNIQUE (d) None of these
33 The clause that allows sorting of the query results by one or more columns
(a) GROUP BY (b) ORDER BY
67
(c ) ASC (d) None of these
34 The clause lets the user to split up the values in a column into subsets.
(a) GROUP BY (b) ORDER BY
(c ) ASC (d) None of these
35 A virtual table whose contents are defined by a query
(a) VIEW (b) TABLE
(c ) RELATION (d) None of these
36 The SQL command that is used to remove an entire row of data from a
table
(a) DELETE (b) DROP
(c ) Update (d) None of these
37 Which of the following SQL Commands is used to modify the structure of a
table
(a) DROP TABLE (b) ALTER TABLE
(c ) CREATE TABLE (d) None of these
38 Which of these functions is used to find the total summation of a column
(a) ADD (b) COUNT
(c ) SUM (d) AVG
39 Which of these clause is not used with SELECT command
(a) MODIFY (b) WHERE
(c ) ORDER BY (d) GROUP BY
40 Which of these is not an aggregate function in SQL?
(a) COUNT(*) (b) AVG
(c ) MIN( ) (d) Date
41 Which of these clauses is used for pattern matching?
(a) LIKE (b) BETWEEN AND
(c ) IN (d) IS NULL
68
UNIT 4: BOOLEAN ALGEBRA
13 In which law, the logical addition and logical multiplication of two variables
is commutative in nature.
69
(a) Associative (b) Commutative
(c) Distributive (d) None of these
14 According to Commutative law , which of the following statement is
correct
(a) A+B = B+A (b) A.B = B.A
(c) Both (a) & (b) (d) None of these
15 In which law, the logical addition and logical multiplication of three
variables are associative in nature.
(b) Associative (b) Commutative
(c) Inverse (d) None of these
16 According to Associative law , which of the following statement is
correct
(a) A+(B+C) = (A+B)+C (b) A.(B.C) = (A.B).C
(c) Both (a) & (b) (d) None of these
17 In which law, the logical addition and logical multiplication of three
variables is distributive in nature.
(a) Associative (b) Commutative
(c) Distributive (d) None of these
18 According to Distributive law , which of the following statement is
correct
(a) A.(B+C) = (A.B)+(A.C) (b) A+(B.C) = (A+B).(A+C)
(c) Both (a) & (b) (d) None of these
19 In which law, the logical addition and logical multiplication of two variables
is absorptive in nature.
(a) Absorption (b) De Morgan
(c) Inverse (d) None of these
20 According to Absorption law , which of the following statement is correct
(a) A+A.B = A (b) A.(A+B) = A
(c) Both (a) & (b) (d) None of these
21 Which one of the following is best correct for Idempotence law, which
states that for every logical variable A there exists A such that
(a) A + A = A (b) A.A = A
(c) Both (a) & (b) (d) None of these
22 Which one of the following is best correct for Inverse law, which states
that for every logical variable A there exists A’ such that
(a) A + Ā = 1 (b) A. Ā = 0
(c) Both (a) & (b) (d) None of these
23 Which one of the following is best correct for Involution law, which
states that for every logical variable A there exists A’ such that
70
(a) ((A’)’) = A (b) ((A’)’) = 1
(c) ((A’)’) = 0 (d) None of these
24 De Morgan’s Law states that for every two logical variables A and B
(a) (A +B)’ = A’. B’ (b) (A.B)’ = A’ + B’
(c) Both (a) & (b) (d) None of these
25 The principle that states that any valid Boolean expression of Boolean
algebra remains valid even if the logical operators and the logical
constants in the expression are interchanged.
(a) Duality Principle (b) Commutative Principle
(c) Associative Principle (d) None of these
26 The dual of an expression can be obtained by following these rules
(a) Interchanging OR and AND operators.
(b) Interchanging ‘+’ and ‘.’ Signs.
(c) Replacing 0s by 1s and 1s by 0s.
(d) All of the above
27 The term in a Boolean expression, which is a logical multiplication of two
or more Boolean variables (either in normal or complemented form) is
called
(a) Product term (b) Sum term
(c) Minterm (d) Maxterm
28 The term in a Boolean expression, which is a logical addition of two or
more Boolean variables (either in normal or complemented form) is called
(a) Product term (b) Sum term
(c) Minterm (d) Maxterm
71
(a) Standard form (b) Non standard form
(c) Canonical form (d) None of the above
72
( c) 00,11,01,10 (d) None of these
43 In K-map, grouping of terms is always done in the power of ............(2).
44 A group of two 1s is called a .............(pair), a group of four 1s is called a
....... (quad) and a group of eight 1s is known as an .............(octet).
45 In K-map, a pair cancels ............(one) variable, a quad cancels ...........(two)
variables and an octet cancels ..............(three) variables.
46 An electronic circuit that takes one or more input signals and produces
only one output signal is called a ............( gate).
47 Which of these are basic gates are
(a) NOT (b) AND
(b) OR (d) All of these
48 Which of these is Universal gate
(a) NAND (b) NOR
(c ) Both (a) & (b) (d) None of these
49 Which of these performs the logical addition in a Boolean algebra
(a) OR (b) AND
(c ) NOT (d) NAND
50 Which of these is also known as complement operator?
(a) OR (b) AND
(c ) NOT (d) NAND
51 Which of these is a valid complemented OR gate?
(a) OR (b) XOR
(c ) XNOR (d) NOR
73
UNIT 5: NETWORKING AND OPEN SOURCE
SOFTWARE
74
(a) Channel (b) wireless
( c ) satellite ( d) None of these
11 The maximum volume of data that can be transferred over any
communication channel at a given point of time is known as
(a) Bandwidth (b) Data Transfer rate
( c ) Baud ( d) None of these
12 The unit of bandwidth in analog system is
(a) bits per second (b) hertz
( c ) baud ( d) None of these
13 The unit of bandwidth in digital system is
(a) bits per second (b) hertz
( c ) baud ( d) None of these
14 The amount of data transferred per second by the communication channel
from one point to another is known as
(a) Bandwidth (b) Data Transfer rate
( c ) Baud ( d) None of these
15 The unit of data transfer rate is
(a) bits per second (b) bytes per second
( c ) baud ( d) All of the above
16 The inexpensive transmission media that is used for transmission of
analog as well as digital signals
(a) Twisted Pair Cable (b) Co-axial Cable
( c ) Optical Fibre ( d) None of these
17 The transmission media that are capable of transmitting digital signals at
a very high speed with bandwidth 1 GHz and are immune to noise
(a) Twisted Pair Cable (b) Co-axial Cable
( c ) Optical Fibre ( d) None of these
18 The transmission media that can transmit data over long distance with
high security with bandwidth up to 10Gbps
(a) Twisted Pair Cable (b) Co-axial Cable
( c ) Optical Fibre ( d) None of these
19 The high frequency waves used for short range communication and are
used in TV remotes, garage doors, wireless speakers
(a) Microwave (b) Radio Wave
( c ) Infrared Wave ( d) None of these
20 The transmission media that facilitates mobility for long distances are
(a) Microwave (b) Radio Wave
( c ) Infrared Wave ( d) None of these
21 The line of sight transmission media that facilitates easy communication
in mountainous areas and over oceans
(a) Microwave (b) Radio Wave
75
(c) Infrared Wave ( d) None of these
22 The transmission media that covered a quite large and there is no line of
sight restriction is
(a) Microwave (b) Radio Wave
( c ) Infrared Wave ( d) Satellite
23 The device that convert analog signal into digital and digital signal into
analog is known as
(a) MODEM (b) HUB
( c ) SWITCH ( d) Gateway
24 The multi port device that works on IP addresses and broadcast the
signals is
(a) MODEM (b) HUB
( c ) SWITCH ( d) Gateway
25 The network device that works on the physical address and filter the
network signals is
(a) MODEM (b) HUB
( c ) SWITCH ( d) Gateway
26 An interconnecting device which joins two dissimilar networks with the
help of different protocols
(a) MODEM (b) HUB
( c ) SWITCH ( d) Gateway
27 The four wire connector that is used to connect telephone network
(a) RJ45 (b) RJ11
( c ) Ethernet ( d) None of these
28 The eight wire connector that is used to connect Ethernet network or
computer network
(a) RJ45 (b) RJ11
( c ) Ethernet ( d) None of these
29 A privately owned computer network that is confined to an area of few
kilometres
(a) LAN (b) MAN
( c ) WAN ( d) None of these
30 A computer network usually spreading over a metropolitan area such as a
city and the suburbs
(a) LAN (b) MAN
( c ) WAN ( d) None of these
31 A computer network that spreads over a large geographical area like a
country or a continent
(a) LAN (b) MAN
( c ) WAN ( d) None of these
76
32 The topology that uses a common single cable to connect all the
workstations
(a) Bus (b) Star
(c ) Tree (d) None of these
33 The topology in which the devices are connected through a centralized
network component known as hub or switch
(a) Bus (b) Star
(c ) Tree (d) None of these
34 The topology that combines the characteristics of the linear bus and the
star topology known as
(a) Bus (b) Star
(c ) Tree (d) None of these
35 The layered set of protocols that handles the way data is transmitted
across Internet
(a) TCP / IP (b) FTP
(c ) PPP (d) Telnet
36 A Protocol that is used to transfer information between computers on the
Internet
(a) TCP / IP (b) FTP
(c ) PPP (d) Telnet
37 The protocol that provides the ability to transport TCP / IP traffic over
serial lines
(a) SLIP / PPP (b) FTP
(c ) Telnet (d) None of these
38 The protocol that is used to send the e-mail over Internet
(a) SMTP (b) FTP
(c ) POP3 (d) Telnet
39 The protocol that is used to receive the e-mail over Internet
(a) SMTP (b) FTP
(c ) POP3 (d) Telnet
40 The protocol that is used for chat and video conferencing
(a) SMTP (b) FTP
(c ) POP3 (d) VOIP
41 A non self replicating program that appears to perform a desirable
function for the user but instead facilitates unauthorized access to the
user's computer system.
(a) Virus (b) WORM
(c ) Trojan Horse (d) Spam
77
42 A program that is capable of replicating itself on a computer network
(a) Virus (b) WORM
(c ) Trojan Horse (d) Spam
43 A software program that is capable of reproducing itself the help of
other executable files
(a) Virus (b) WORM
(c ) Trojan Horse (d) Spam
44 Electronic junk mail are known as
(a) Virus (b) WORM
(c ) Trojan Horse (d) Spam
45 Which one of the following is not a client side scripting language
(a) VB Script (b) Java Script
(c ) PHP (d) ASP
46 Which one of the following is not a server side scripting language
(a) JSP (b) Java Script
(c ) PHP (d) ASP
47 The software that is owned by an individual or a company
(a) Proprietary (b) Open Source
(c ) Freeware (d) Shareware
48 The software whose source code is freely available
(a) Proprietary (b) Open Source
(c ) Freeware (d) Shareware
49 The software which are available freely and whose source code may or
may not be free
(a) Proprietary (b) Open Source
(c ) Freeware (d) Shareware
50 Software that is available free of charge and often distributed informally
for evaluation, after which a fee may be requested for
(a) Proprietary (b) Open Source
(c ) Freeware (d) Shareware
51 The computing that relies on sharing computing resources rather than
having local servers or personal devices to handle applications.
(a) Cloud Computing (b) Network Computing
(c ) Mobile Computing (d) None of these
52 The cloud infrastructure operated solely for a single organization,
whether managed internally or by a third-party ...
(a) Private Cloud (b) Public Cloud
(c ) Community Cloud (d) Hybrid Cloud
78
53 The cloud computing in which the services are rendered over a network
that is open for public use.
(a) Private Cloud (b) Public Cloud
(c ) Community Cloud (d) Hybrid Cloud
54 The cloud computing that is the combination of two or more clouds
(a) Private Cloud (b) Public Cloud
(c ) Community Cloud (d) Hybrid Cloud
55 The open forum for discussing, sharing, and collaborating on Cloud
Computing
(a) Private Cloud (b) Public Cloud
(c ) Community Cloud (d) Hybrid Cloud
79
80