- Total Questions: 100
- Duration: 40 minutes
- Type: Objective-type multiple choice questions (MCQs)
- For all type of competitive examination
- Questions Level: Engineering/Diploma level in Computer Science
Topics Covered:
·
OOPs Concept & Features
·
Constructors
and Destructors
·
Access
Specifiers
·
Class Members & Types
·
Object
·
Classes
·
Class
Components
·
Types of Classes
·
Inheritance
& its Types
·
Polymorphism
·
Member Functions & its Types
·
Exception Handling & Static Class Members
1. Which was the first purely object oriented programming language developed?
a) Java
b) C++
c) SmallTalk
d) Kotlin
2. Which of the following best defines a class?
a) Parent of an object
b) Instance of an object
c) Blueprint of an object
d) Scope of an object
3. Who invented OOP?
a) Alan Kay
b) Andrea Ferro
c) Dennis Ritchie
d) Adele Goldberg
4. What is the additional feature in classes that was not in structures?
a) Data members
b) Member functions
c) Static data allowed
d) Public access specifier
5. Which is not feature of OOP in general definitions?
a) Code reusability
b) Modularity
c) Duplicate/Redundant data
d) Efficient Code
6. Which Feature of OOP illustrated the code reusability?
a) Polymorphism
b) Abstraction
c) Encapsulation
d) Inheritance
7. Which language does not support all 4 types of inheritance?
a) C++
b) Java
c) Kotlin
d) Small Tal
8. How many classes can be defined in a single program?
a) Only 1
b) Only 100
c) Only 999
d) As many as you want
9. When OOP concept did first came into picture?
a) 1970’s
b) 1980’s
c) 1993
d) 1995
10. Why Java is Partially OOP language?
a) It supports usual declaration of primitive data types
b) It doesn’t support all types of inheritance
c) It allows code to be written outside classes
d) It does not support pointers
11. Which concept of OOP is false for C++?
a) Code can be written without using classes
b) Code must contain at least one class
c) A class must have member functions
d) At least one object should be declared in code
12. Which header file is required in C++ to use OOP?
a) iostream.h
b) stdio.h
c) stdlib.h
d) OOP can be used without using any header file
13. Which of the two features match each other?
a) Inheritance and Encapsulation
b) Encapsulation and Polymorphism
c) Encapsulation and Abstraction
d) Abstraction and Polymorphism
14. Which feature allows open recursion, among the following?
a) Use of this pointer
b) Use of pointers
c) Use of pass by value
d) Use of parameterized constructor
15. Which among the following is called first, automatically, whenever an object is created?
a) Class
b) Constructor
c) New
d) Trigger
16. Which among the following is not a necessary condition for constructors?
a) Its name must be same as that of class
b) It must not have any return type
c) It must contain a definition body
d) It can contains arguments
17. Which among the following is correct?
a) class student{ public: int student(){} };
b) class student{ public: void student (){} };
c) class student{ public: student{}{} };
d) class student{ public: student(){} };
18. In which access should a constructor be defined, so that object of the class can be created in any function?
a) Public
b) Protected
c) Private
d) Any access specifier will work
19. How many types of constructors are available for use in general (with respect to parameters)?
a) 2
b) 3
c) 4
d) 5
20. If class C inherits class B. And B has inherited class A. Then while creating the object of class C, what will be the sequence of constructors getting called?
a) Constructor of C then B, finally of A
b) Constructor of A then C, finally of B
c) Constructor of C then A, finally B
d) Constructor of A then B, finally C
21. In multiple inheritance, if class C inherits two classes A and B as follows, which class constructor will be called first?
a) A()
b) B()
c) C()
d) Can’t be determined
22. Which among the following is true for copy constructor?
a) The argument object is passed by reference
b) It can be defined with zero arguments
c) Used when an object is passed by value to a function
d) Used when a function returns an object
23. If the object is passed by value to a copy constructor?
a) Only public
members will be accessible to be copied
b) That will work normally
c) Compiler will give out of memory error
d) Data stored in data members won’t be accessible
24. Which object will be created first?
class student
{
int marks;
};
student s1, s2, s3;
a) s1 then s2 then s3
b) s3 then s2 then s1
c) s2 then s3 then s1
d) all are created at same time
25. For constructor overloading, each constructor must differ in and
a) Number of arguments and type of arguments
b) Number of arguments and return type
c) Return type and type of arguments
d) Return type and definition
26. How many types of access specifiers are provided in OOP (C++)?
a) 1
b) 2
c) 3
d) 4
27. Which among the following can be used together in a single class?
a) Only private
b) Private and Protected together
c) Private and Public together
d) All three together
28. Which among the following can restrict class members to get inherited?
a) Private
b) Protected
c) Public
d) All three
29. Which access specifier is used when no access specifier is used with a member of class (java)?
a) Private
b) Default
c) Protected
d) Public
30. Which specifier allows a programmer to make the private members which can be inherited?
a) Private
b) Default
c) Protected
d) Protected and default
31. Which among the following is false?
a) Private members can be accessed using friend functions
b) Member functions can be made private
c) Default members can’t be inherited
d) Public members are accessible from other classes also
32. If a class has all the private members, which specifier will be used for its implicit constructor?
a) Private
b) Public
c) Protected
d) Default
33. Which access specifier should be used in a class where the instances can’t be created?
a) Private default constructor
b) All private constructors
c) Only default constructor to be public
d) Only default constructor to be protected
34. On which specifier’s data, does the size of a class’s object depend?
a) All the data members are added
b) Only private members are added
c) Only public members are added
d) Only default data members are added
35. If class B inherits class A privately. And class B has a friend function. Will the friend function be able to access the private member of class A?
a) Yes, because friend function can access all the members
b) Yes, because friend function is of class B
c) No, because friend function can only access private members of friend class
d) No, because friend function can access private member of class A also
36. If an abstract class has all the private members, then
a) No class will be able to implement members of abstract class
b) Only single inheritance class can implement its members
c) Only other enclosing classes will be able to implement those members
d) No class will be able to access those members but can implement.
37. Which access specifier should be used so that all the parent class members can be inherited and accessed from outside the class?
a) Private
b) Default or public
c) Protected or private
d) Public
38. Which access specifier is usually used for data members of a class?
a) Private
b) Default
c) Protected
d) Public
39. Which specifier should be used for member functions of a class?
a) Private
b) Default
c) Protected
d) Public
40. What is the term used to indicate the variable and constants of a class?
a) Data members
b) Variables of class
c) Data characters
d) Constants
41. Data members (C++)
a) Can be initialized with declaration in classes
b) Can be initialized only with help of constructors
c) Can be initialized either in declaration or by constructor
d) Can’t be initialized
42. Which among the following is true for data members?
a) Private data members can be initialized with declaration in class
b) Static members are initialized in constructors
c) Protected data members can be initialized in class directly
d) Static data members are defined outside class, not in constructor
43. What should be done for data member to be of user defined structure type?
a) The structure must have been defined before class.
b) The structure must have been defined after the class definition
c) The structure must be predefined
d) The structure type data members can’t be used
44. How many data members can a class contain?
a) 27
b) 255
c) 1024
d) As many as required
45. How to access data members of a class?
a) Dot operator
b) Arrow operator
c) Dot or arrow as required
d) Dot, arrow or direct call
46. Which among the following is true for use of setter() and getter() function?
a) Considered best for manipulating data values
b) Considered the only proper way to manipulate the values
c) Considered specially for private members manipulation
d) Considered a red flag, and not recommended for large scale use
47. What is the output of following code?
int
n=10; // global class A()
{
private : int n; public
: int
m; A()
{
n=100; m=50;
}
void disp()
{
cout<<”n”<<m<<n;
};
a) 1050100
b) 1005010
c) n5010
d) n50100
48. The static member functions can only use
a) Static data members
b) Private data members
c) Protected data members
d) Constant data members
49. What is the keyword used to make data members have same value?
a) static
b) const
c) double
d) abstract
50. Which data members can be inherited but are private to a class?
a) Private
b) Protected
c) Protected and Static
d) Privately inherited
51. Which among the following is not allowed for data member declaration?
a) int a;
b) static int a;
c) abstract a;
d) Boolean a;
52. In how many ways can an object be passed to a function?
a) 1
b) 2
c) 3
d) 4
53. If an object is passed by value
a) A new copy of object is created implicitly
b) The object itself is used
c) Address of the object is passed
d) A new object is created with new random values
54. Pass by address passes the address of object and pass by reference passes the address of the object
a) Explicitly, explicitly
b) Implicitly, implicitly
c) Explicitly, Implicitly
d) Implicitly, explicitly
55. If an object is passed by reference, the changes made in the function
a) Are reflected to the main object of caller function too
b) Are reflected only in local scope of the called function
c) Are reflected to the copy of the object that is made during pass
d) Are reflected to caller function object and called function object also
56. Constructor function is not called when an object is passed to a function, will its destructor be called when its copy is destroyed?
a) Yes, depending on code
b) Yes, must be called
c) No, since no constructor was called
d) No, since same object gets used
57. When an object is returned by a function, a is automatically
created to hold the return value.
a) Temporary object
b) Virtual object
c) New object
d) Data member
58. Is the destruction of temporary object safe (while returning object)?
a) Yes, the resources get free to use
b) Yes, other objects can use the memory space
c) No, unexpected side effects may occur
d) No, always gives rise to exceptions
59. How to overcome the problem arising due to destruction of temporary object?
a) Overloading insertion operator
b) Overriding functions can be used
c) Overloading parenthesis or returning object
d) Overloading assignment operator and defining copy constructor
60. How many objects can be returned at once?
a) Only 1
b) Only 2
c) Only 16
d) As many as required
61. It is necessary to return the object if it was passed by reference to a function.
a) Yes, since the object must be same in caller function
b) Yes, since the caller function needs to reflect the changes
c) No, the changes are made automatically
d) No, the changes are made explicitly
62. How many objects can be passed to a function simultaneously?
a) Only 1
b) Only an array
c) Only 1 or an array
d) As many as required
63. If an object is passed by address, will be constructor be called?
a) Yes, to allocate the memory
b) Yes, to initialize the members
c) No, values are copied
d) No, temporary object is created
64. Which among the following best describes abstract classes?
a) If a class has more than one virtual function, it’s abstract class
b) If a class have only one pure virtual function, it’s abstract class
65. Can abstract class have main() function defined inside it?
a) Yes, depending on return type of main()
b) Yes, always
c) No, main must not be defined inside abstract class
d) No, because main() is not abstract function
66. If there is an abstract method in a class then,
a) Class must be abstract class
b) Class may or may not be abstract class
c) Class is generic
d) Class must be public
67. Abstract classes can instances.
a) Never have
b) Always have
c) Have array of
d) Have pointer of
68. The abstract classes in java can
a) Implement constructors
b) Can’t implement constructor
c) Can implement only unimplemented methods
d) Can’t implement any type of constructor
69. Which is most appropriate definition of a base class?
a) It is parent of any of its derived class
b) It is child of one of the parent class
c) It is most basic class of whole program
d) It is class with maximum number of members
70. A base class is also known as class.
a) Basic
b) Inherited
c) Super
d) Sub
71. An abstract class is always a class.
a) Base
b) Derived
c) Template
d) Nested
72. How many base classes can a single class inherit in java?
a) 1
b) 2
c) 3
d) As many as required
73. How to make a derived class a base class?
a) Change name of the class
b) Use keyword base
c) Make a class derive from it
d) Can’t be done
74. If a base class is being derived by two other classes, which inheritance will that be called?
a) Single
b) Multiple
c) Multi-level
d) Hierarchical
75. Which type of members can’t be accessed in derived classes of a base class?
a) Protected
b) Private
c) Public
d) All can be accessed
76. Always the base class constructors are called constructor of derived
class.
a) Before
b) After
c) Along
d) According to priority of
77. If a base class is inherited from another class and then one class derives it, which
inheritance is shown?
a) Multiple
b) Single
c) Hierarchical
d) Multi-level
78. How many base classes can a single derived class have in C++?
a) 1
b) 2
c) 3
d) As many as required
79. Which among the following is best definition of a derived class?
a) A child class
b) A class which inherits one or more classes
c) A class with keyword derived
d) A class with more than one constructor
80. Which among the following is inherited by a derived class from base class?
a) Data members only
b) Member functions only
c) All the members except private members
d) All the members of base class
81. Which members can never be accessed in derived class from the base class?
a) Private
b) Protected
c) Public
d) All except private
82. Derived class is also known as class.
a) Subclass
b) Small class
c) Big class
d) Noticeable class
83. Which among the following best defines single level inheritance?
a) A class inheriting a derived class
b) A class inheriting a base class
c) A class inheriting a nested class
d) A class which gets inherited by 2 classes
84. Which programming language doesn’t support multiple inheritance?
a) C++ and Java
b) C and C++
c) Java and SmallTalk
d) Java
85. Which type of inheritance leads to diamond problem?
a) Single level
b) Multi-level
c) Multiple
d) Hierarchical
86. Which access type data gets derived as private member in derived class?
a) Private
b) Public
c) Protected
d) Protected and Private
87. What will be the output of the following Java code?
class Calc
{
public int disp()
{
return 10;
}
public long disp()
{
return 11;
}
public static void main(String[] args)
{
Calc obj = new Calc(); System.out.println(obj.disp());
}
}
a) 10
b) 11
c) Compilation Error
d) Null
88. . What will be the output of the following Java code?
class Base
{
public void show()
{
System.out.println("Base");
}
}
class Derived extends Base
{
public void show()
{
System.out.println("Derived");
}
}
public class Overriding
{
public static void main(String[] args)
{
Base i = new Derived();
i.show();
}
}
a) Base
b) Compilation Error
c) Derived
d) Runtime Error
89. What is an exception?
a) Problem arising during compile time
b) Problem arising during runtime
c) Problem in syntax
d) Problem in IDE
90. Why do we need to handle exceptions?
a) To prevent abnormal termination of program
b) To encourage exception prone program
c) To avoid syntax errors
d) To save memory
91. An exception may arise when
a) Input is fixed
b) Input is some constant value of program
c) Input given is invalid
d) Input is valid
92. Which among the following is not a method of Throwable class?
a) public String getMessage()
b) public Throwable getCause()
c) public Char toString()
d) public void printStackTrace()
93. Multiple catch blocks
a) Are mandatory for each try block
b) Can be combined into a single catch block
c) Are not possible for a try block
d) Can never be associated with a single try block
94. Which class is used to handle the input and output exceptions?
a) InputOutput
b) InputOutputExceptions
c) IOExceptions
d) ExceptionsIO
95. Why do we use finally block?
a) To execute the block if exception occurred
b) To execute a code when exception is not occurred
c) To execute a code whenever required
d) To execute a code with each and every run of program
96. he static member functions
a) Have access to all the members of a class
b) Have access to only constant members of a class
c) Have access to only the static members of a class
d) Have direct access to all other class members also
97. The static member functions
a) Can be called using class name
b) Can be called using program name
c) Can be called directly
d) Can’t be called outside the function
98. Which is correct syntax to access the sta
tic member functions with class name?
a) className . functionName;
b) className -> functionName;
c) className : functionName;
d) className :: functionName;
99. The static members are
a) Created with each new object
b) Created twice in a program
c) Created as many times a class is used
d) Created and initialized only once
100. Which keyword should be used to declare the static member functions?
a) static
b) stat
c) const
d) common
101. The keyword static is used
c) With declaration and definition wherever done
d) With each call to the member function
102. We can use the static member functions and static data member
a) Even if class object is not created
b) Even if class is not defined
103. The static data member
a) Can be mutable
b) Can’t be mutable
c) Can’t be integer
d) Can’t be characters
104. If static data member are made inline,
a) Those should be initialized outside the class
b) Those can’t be initialized with the class
c) Those can be initialized within the class
d) Those can’t be used by class members
THANK YOU FOR WATCHING THIS VIDEO
WRITE DOWN NEXT TOPICS IN COMMENT BOX
LIKE, SHARE AND SUBSCRIBE TO US @LEARNINEASYWAY
SEE YOU IN NEXT VIDEO!
Comments
Post a Comment