Wednesday 12 March 2014

DATA STRUCTURES MCQS

1) Additional information sent when an exception is thrown may be placed in 
 A. The throw keyword
 B. The function that caused the error
 C. The catch block
 D. An object of the exception class
 Ans:- C

2) It is possible to declare as a friend 
 A. A member function
 B. A global function
 C. A class
 D. All of the above
Ans:- D

3) In a class specifier ,data or function designated private are accessible 
 A. To any function in the program
 B. Only if you the password
 C. To member functions of that class
 D. Only to public members of the class
Ans:-C

4) What is the output of the following code
char symbol[3]={‘a’,‘b’,‘c’};
for (int index=0; index<3; index++)
cout << symbol [index]; 
 A. a b c
 B. “abc”
 C. abc
 D. ‘abc’
Ans:-C

5) This pointer 
 A. Implicitly points to an object
 B. Can be explicitly used in a class
 C. Can be used to return an object
 D. All of the above
Ans:- D

6) cfront 
 A. is the front end of a C compiler
 B. is the per-process of a C compiler
 C. is a tool that is translated a C++ code to its equivalent C code
 D. None of above
Ans:- C

7) A pure virtual function is a virtual function that 
 A. Has no body
 B. Returns nothing
 C. Is used in base class
 D. Both (A) and (C)
Ans:-D

8) Access to private data 
 A. Restricted to methods of the same class
 B. Restricted to methods of other classes
 C. Available to methods of the same class and other classes
 D. Not an issue because the program will not compile
Ans:-B

9) What will be the output of the following program?
#include<iostream.h>
void main()
{
float x=5,y=2;
int result;
result=x % y;
cout<<result;

 A. 1
 B. 1.0
 C. Error message
 D. 2.5
Ans:- C

10) 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
Ans:- B

11) _________ members of a base class are never accessible to a derived class. 

 A. Public
 B. Private
 C. Protected
 D. A,B and C
Ans:- B

12) Real world objects contain 
 A. State and behavior
 B. Date and time
 C. Data and information
 D. None of these
Ans:- A

13) This type of inheritance is a mixture of multiple inheritance and hierarchical inheritance 
 A. Single inheritance
 B. Multiple inheritance
 C. Hierarchical inheritance
 D. Hybrid inheritance
Ans:- D

14) 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
Ans:-C

15) Within a switch statement 
 A. Continue can be used but Break cannot be used
 B. Continue cannot be used but Break can be used
 C. Both Continue and Break can be used
 D. Neither Continue nor Break can be used
Ans:-B

16) A virtual class is the same as 
 A. An abstract class
 B. A class with a virtual function
 C. A base class
 D. None of the above
Ans:- D

17) 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
Ans:- C

18) Which of the following cannot be legitimately passed to a function 
 A. A constant
 B. A variable
 C. A structure
 D. A header file
Ans:- D

19)If x =5, y =2 then x ^y equals________.
(where ^ is a bitwise XOR operator) 
 A. 00000111
 B. 10000010
 C. 10100000
 D. 11001000
Ans:-  A 

20) In multiple inheritance 
 A. The base classes must have only default constructors
 B. Cannot have virtual functions
 C. Cannot have virtual classes
 D. None of the above
Ans:-  C

Tuesday 11 March 2014

DATA STRUCTURES MCQS

1) The C language includes the header file standard input & output in 
 A. stdlib.h library
 B. stdio.h library
 C. conio.h library
 D. #include library
 Ans:- B

2) Consider the following recursive C function that takes two arguments. unsigned int foo(unsigned int n,unsigned int r) { if(n>0)return((n%r)+foo(n/r,r)); else return 0; } What is value of function foo when it called as foo(512,2)? 
 A. 9
 B. 2
 C. 8
 D. 11
Ans:- B

3) What would be output of the following program?
# define SQR(X) (X*X)
main()
{
int a, b=3;
a = SQR(b+2);
printf(“\n%d”, a);

 A. 25
 B. 11
 C. Error
 D. Garbage value
Ans:- B

4) Number of possible binary trees with 3 nodes is 
 A. 12
 B. 13
 C. 14
 D. 15
Ans:- D

5) The expression X=4+2%-8 evaluate 
 A. -6
 B. 6
 C. 4
 D. None
Ans:-B

6) The data structure needed to convert a recursion to an iterative procedure is 
 A. Queue
 B. Graph
 C. Stack
 D. Tree
Ans:-C

7) What punctuation is used to signal the beginning and end of code blocks? 
 A. { }
 B. -> and <-
 C. BEGIN and END
 D. ( and )
Ans:-A

8) What is the output of the following program segment?
main()
{
int i = ++2;
printf(“%d\n”, i);

 A. 3
 B. 2
 C. 0
 D. -1
Ans:-A

9) An algorithm that calls itself directly or indirectly is known as 
 A. Sub algorithm
 B. Recursion
 C. Polish notation
 D. Traversal algorithm
Ans:-B

10) A Compiler is _____________________. 
 A. A combination of computer hardware
 B. A program which translates from one high-level language to another
 C. A program which translates from one high-level to a machine level
 D. None of these
Ans:-C

11) A binary tree in which if all its levels except possibly the last, have the maximum number of nodes and all the nodes at the last level appear as far left as possible, is known as 
 A. Full binary tree
 B. AVL tree
 C. Threaded tree
 D. Complete binary tree
Ans:-A

12) Which allows deletion at only one end of the list but allows insertion at both ends of the list? 
 A. Deque
 B. Circular queue
 C. Output restricted deque
 D. Input restricted deque
Ans:-C

13) A technique for direct search is 
 A. Binary Search
 B. Linear Search
 C. Tree Search
 D. Hashing
Ans:-D

14) The maximum value that an integer constant can have is 
 A. .32767
 B. 32767
 C. 1.7014e+38
 D. –1.7014e+38
Ans:- B

15) What would be output of the following program?
#include "stdio.h"
main()
{
printf(“%d%d”, size of (NULL!), size of (“ “));

 A. 2 1
 B. 1 2
 C. 2 2
 D. 1 1
Ans:-  C

16) It is necessary to declare the type of function in the calling program if 
 A. Function returns an integer
 B. Function returns a non-integer value
 C. Function is not defined in the same file
 D. Function is called number of times
Ans:-  B

17) The smallest element of an array’s index is called its 
 A. Lower bound
 B. Upper bound
 C. Range
 D. Extraction
Ans:-A

18) C language was invented by 
 A. Abacus
 B. Charles babage
 C. Thomson
 D. Dennis Ritchie
Ans:- D

19) The _______ operator is a technique to forcefully convert one data type to the others 
 A. Cast
 B. Conversion
 C. Type
 D. Unary
Ans:-A

20) A binary tree whose every node has either zero or two children is called 
 A. Complete binary tree
 B. Binary search tree
 C. Extended binary tree
 D. None of above
Ans:-C

DATA STRUCTURES MCQS

1) What will be output if you will execute following c code?
#include<stdio.h> int main(){    int i;    for(i=0;i<5;i++){         int i=10;         printf(" %d",i);         i++;    }    return 0; 
 A. 10 11 12 13 14
 B. 10 10 10 10 10 
 C. 0 1 2 3 4
 D. Compilation error
  Ans:-  B
  Explanation Default storage class of local variable is auto. Scope of auto variables are block in which it has been declared. When program control goes out of the scope auto variables are dead. So variable iwhich has been declared inside for loop has scope within loop and in each iteration variable i is dead and re-initialized. Note: If we have declared two variables of same name but different scope then local variable will have higher priority 

2) Which of the following data structure is used to represent relationship between pairs, where relationship is not hierarchical ? 
 A. Graph
 B. Tree
 C. Hash Table
 D. Queue
Ans:- A

3) Which of the following data structure is used to represent hierarchical relationship among its elements? 
 A. Graph
 B. Tree
 C. Hash Table
 D. Queue
Ans:-B

4) If a binary tree satisfies shape and order property its known as  
 A. Binary Search Tree
 B. Sequential Search Tree
 C. Heap
 D. Rooted Tree
Ans:- C

5) A data structure in which linear sequence is maintained by pointers is known as 
 A. Pointer based data structure
 B. Stack
 C. Array
 D. Linklist
Ans:- D

6) A data structure whose elements from a sequence is known as 
 A. Non-linear Data Structure
 B. Linear Data Structure
 C. Homogeneous Data Structure
 D. Heterogeneous Data Structure
Ans:- B

7) Each attribute of an entity has a defined set of values. This set of values is called a 
 A. Range
 B. Domain
 C. Entity Set
 D. Mapping
Ans:-B

8) A data item that cannot be divided into sub items is known as 
 A. Primary Data Item
 B. Primary Key
 C. Group Data Item
 D. Elementary Data Item
Ans:- C

9)Inheritance is a feature of --------------language 
 A. C Language
 B. C++ Language
 C. Basic
 D. Cobol
Ans:- B 

10) The statement that transfers control to the beginning of the loop is called 
 A. Break statement
 B. Exit statement
 C. Continue statement
 D. Goto statement
Ans:- C

11) The language that the computer can understand and execute is called 
 A. Machine Language
 B. Application Software
 C. System Program
 D. Assembly language
Ans:-A

12) The keyword used to transfer control from a function back to the calling function is 
 A. Switch
 B. Goto
 C. Go back
 D. Return
Ans:- D

13) If an array is used as function argument, the array is passed 
 A. By value
 B. By reference
 C. By name
 D. The array cannot be used as a function argument
Ans:-B

14) In C, if you pass an array as an argument to a function, what actually gets passed? 
 A. Value of elements in array
 B. First element of the array
 C. Base address of the array
 D. Address of the last element of array
Ans:-C

15) The break statement causes an exit 
 A. Only from the innermost loop
 B. Only from the innermost switch
 C. From the innermost loop or switch
 D. From the program
Ans:- C

16) The smallest element of an array’s index is called its 
 A. Lower bound
 B. Upper bound
 C. Range
 D. Extraction
Ans:-  A

17) If a = 5 and b = 7 then the statement p = (a > b) : a ? b 
 A. assigns a value 5 to p
 B. assigns a value 7 to p
 C. assigns a value 8 to p
 D. gives an error message
Ans:-  D

18) The __________ statement causes immediate exit from the loop overriding the condition test 
 A. Exit
 B. Break
 C. Goto
 D. None of the above
Ans:- B

19) The value that follows the keyword CASE may only be 
 A. Constants
 B. Variable
 C. Number
 D. Semicolon
Ans:- A

20) The machine registers are sometimes called 
 A. Local variables
 B. Global variables
 C. Accumulators
 D. Static variables
Ans:-  A

OBJECT ORIENTED PROGRAMMING MCQS

1) Which can be passed as an argument to a function? 
 A. Constant
 B. Expression
 C. Another function
 D. All of the above
 Ans:- A

2) A class which can use all the features of an established class,is 
 A. A static class
 B. A super class
 C. A subclass
 D. Overloaded
Ans:-C

3) Use of virtual functions implies 
 A. Overloading
 B. Overriding
 C. Static binding
 D. Dynamic binding
Ans:-  D

4) 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. Protected and public data only in C and B
 B. Protected and public data only in C
 C. Private data in A and B
 D. Protected data in A and B
Ans:-D

5) A blueprint for a software object is called a 
 A. Object
 B. Class
 C. Instance
 D. None of these
Ans:-B

6) A friend function to a class, C cannot access 
 A. Private data members and member functions
 B. Public data members and member functions
 C. Protected data members and member functions
 D. The data members of the derived class of C
Ans:-D

OBJECT ORIENTED PROGRAMMING MCQS

1) Additional information sent when an exception is thrown may be placed in 
 A. The throw keyword
 B. The function that caused the error
 C. The catch block
 D. An object of the exception class
 Ans:-C

2) It is possible to declare as a friend 
 A. A member function
 B. A global function
 C. A class
 D. All of the above
 Ans:-D

3) In a class specifier ,data or function designated private are accessible 
 A. To any function in the program
 B. Only if you the password
 C. To member functions of that class
 D. Only to public members of the class
Ans:- C

4) What is the output of the following code
char symbol[3]={‘a’,‘b’,‘c’};
for (int index=0; index<3; index++)
cout << symbol [index]; 
 A. a b c
 B. “abc”
 C. abc
 D. ‘abc’
Ans:- C

5) This pointer 
 A. Implicitly points to an object
 B. Can be explicitly used in a class
 C. Can be used to return an object
 D. All of the above
Ans:-D

6) cfront 
 A. is the front end of a C compiler
 B. is the per-process of a C compiler
 C. is a tool that is translated a C++ code to its equivalent C code
 D. None of above
Ans:-C

7) A pure virtual function is a virtual function that 
 A. Has no body
 B. Returns nothing
 C. Is used in base class
 D. Both (A) and (C)
Ans:- D

8) Access to private data 
 A. Restricted to methods of the same class
 B. Restricted to methods of other classes
 C. Available to methods of the same class and other classes
 D. Not an issue because the program will not compile
Ans:-B

9) What will be the output of the following program?
#include<iostream.h>
void main()
{
float x=5,y=2;
int result;
result=x % y;
cout<<result;

 A. 1
 B. 1.0
 C. Error message
 D. 2.5
Ans:-C

10) 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
Ans:- B

11) _________ members of a base class are never accessible to a derived class. 
 A. Public
 B. Private
 C. Protected
 D. A,B and C
Ans:- B

12) Real world objects contain 
 A. State and behavior
 B. Date and time
 C. Data and information
 D. None of these
Ans:- A

13) This type of inheritance is a mixture of multiple inheritance and hierarchical inheritance 
 A. Single inheritance
 B. Multiple inheritance
 C. Hierarchical inheritance
 D. Hybrid inheritance
Ans:-D

14) 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
Ans:- C

15) Within a switch statement 
 A. Continue can be used but Break cannot be used
 B. Continue cannot be used but Break can be used
 C. Both Continue and Break can be used
 D. Neither Continue nor Break can be used
Ans:-B

16) A virtual class is the same as 
 A. An abstract class
 B. A class with a virtual function
 C. A base class
 D. None of the above
Ans:-D

17) 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
Ans:- C

18) Which of the following cannot be legitimately passed to a function 
 A. A constant
 B. A variable
 C. A structure
 D. A header file
Ans:-D

19) If x =5, y =2 then x ^y equals________.
(where ^ is a bitwise XOR operator) 
 A. 00000111
 B. 10000010
 C. 10100000
 D. 11001000
Ans:-A

20) In multiple inheritance 
 A. The base classes must have only default constructors
 B. Cannot have virtual functions
 C. Cannot have virtual classes
 D. None of the above
Ans:-C

Monday 10 March 2014

OBJECT ORIENTED PROGRAMMING MCQS

1) Which of the following is not the characteristic of constructor?
 A.    They should be declared in the public section.
 B.    They do not have return type.
 C.     They can not be inherited.
 D.     They can be virtual.
 Ans:- D


2) The concept of hierarchical classification is related to
 A.    Abstraction
 B.    Inheritance
 C.     Function overloading
 D.     None
Ans:-  B

3) RunTime polymorphism is achieved by ___________
 A.    Friend function
 B.    Virtual function
 C.     Operator overloading
 D.     Function overloading
Ans:-B

4) When the compiler cannot differentiate between two overloaded constructors, they are called
 A.    Overloaded
 B.    Destructed
 C.     Ambiguous
 D.     Dubious
Ans:-C

5) If we create a file by ‘ifstream’, then the default mode of the file is _________
 A.    ios :: out
 B.    ios :: in
 C.     ios :: app
 D.     ios :: binary
Ans:- B

6) The actual source code for implementing a template function is created when
 A.    The declaration of function appears.
 B.    The function is invoked.
 C.     The definition of the function appears.
 D.     None of the above.
Ans:- B

7) A default catch block catches
 A.    All thrown objects
 B.    No thrown objects
 C.     Any thrown object that has not been caught by an earlier catch block
 D.     All thrown objects that have been caught by an earlier catch block
Ans:-C

8) An exception is caused by
 A.    A hardware problem
 B.    A problem in the operating system
 C.     A syntax error
 D.     A run-time error
Ans:-D

9) You separated a derived class name from its access specifier with
 A.    A colon
 B.    Two colons
 C.     Atleast one space
 D.     A semi colon
Ans:- B

10) When a child class function is called,the compiler looks first for a matching function name in the
 A.    Class of the object using the function name
 B.    Immediate ancestor class
 C.     Base class
 D.     Descendant class
Ans:- A

11) The process of extracting the relevant attributes of an object is known as
 A.    Polymorphism
 B.    Inheritence
 C.     Abstraction
 D.     Data hiding
Ans:-  B

12) You may override the class access specifiers
 A.    Public members
 B.    Public and protected members
 C.     Any specific class members you choose
 D.     No class members
Ans:-  C

13) The following can be declared as friend in a class
 A.    An object
 B.    A class
 C.     A public data member
 D.     A private data member
Ans:-B

14) for (; ;)
 A.    means the test which is done using some expression is always true
 B.    is not valid
 C.     will loop forever
 D.     should be written as for( )
Ans:- C

15) Which of the following will produce a value 10 if x = 9.7?
 A.    floor(x)
 B.    abs(x)
 C.     log(x)
 D.     ceil(x)
Ans:-  D

16) An object is
 A.    One instance of a class
 B.    Another word for a class
 C.     A class with static method
 D.     A method that accesses class
Ans:-  A

17) If a base class destructor is not virtual, then
 A.    It can not have a function body
 B.    It can not be called
 C.     It can not be called when accessed from pointer
 D.     Destructor in derived class can not be called when accessed through a pointer to the base class
Ans:-  D

18) Which of the statements is true in a protected derivation of a derived class from a base class?
 A.    Private members of the base class become protected members of the derived class
 B.    Protected members of the base class become public members of the derived class
 C.     Public members of the base class become protected members of the derived class
 D.     Protected derivation does not affect private and protected members of the derived class
Ans:-  C

19) If the variable count exceeds 100, a single statement that prints “Too many” is
 A.    if (count<100) cout << “Too many”;
 B.    if (count>100) cout >> “Too many”;
 C.     if (count>100) cout << “Too many”;
 D.     None of these.
Ans:-  C

20) If you wanted to sort many large objects or structures, it would be most efficient to
 A.    Place them in an array and sort the array.
 B.    Place pointers to them in an array and sort the array.
 C.     Place them in a linked list and sort the linked list.
 D.     Place references to them in an array and sort the array.
Ans:- C