OOP (2)
OOP (2)
com/oops-mcq)
1. Which of the following language was developed as the first purely object programming language?
1. SmallTalk
2. C++
3. Kotlin
4. Java
2. Who developed object-oriented programming?
1. Adele Goldberg
2. Dennis Ritchie
3. Alan Kay
4. Andrea Ferro
3. Which of the following is not an OOPS concept?
1. Encapsulation
2. Polymorphism
3. Exception
4. Abstraction
4. Which feature of OOPS described the reusability of code?
1. Abstraction
2. Encapsulation
3. Polymorphism
4. Inheritance
5. Which of the following language supports polymorphism but not the classes?
1. Modularity
2. Efficient Code
3. Code reusability
4. Duplicate or Redundant Data
7. Which feature of OOPS derives the class from another class?
1. Inheritance
2. Data hiding
3. Encapsulation
4. Polymorphism
8. Define the programming language, which does not support all four types of inheritance?
1. Smalltalk
2. Kotlin
3. Java
4. C++
9. A single program of OOPS contains _______ classes?
1. Only 1
2. Only 999
3. Only 100
4. Any number
10.Which operator from the following can be used to illustrate the feature of polymorphism?
1. Overloading <<
2. Overloading &&
3. Overloading | |
4. Overloading +=
11.Which two features of object-oriented programming are the same?
1. Global function
2. Local function
3. Function with lowest priority
4. Function with the highest priority
17.Is it true to use polymorphism in the C programming language?
1. True
2. False
18.Which of the following language uses the classes but not the polymorphism concept?
1. Member functions
2. Data members
3. Public access specifier
4. Static Data allowed
21.How many types of polymorphism in the C++ programming language?
1. Virtual function
2. const function
3. Static function
4. Friend function
24.Which of the following class is known as the generic class?
1. Final class
2. Template class
3. Abstract class
4. Efficient code
25.Which operator overloads using the friend function?
1. *
2. ( )
3. ->
4. =
26.Which of the following OOP concept binds the code and data together and keeps them secure
from the outside world?
1. Polymorphism
2. Inheritance
3. Abstraction
4. Encapsulation
27.Which member of the superclass is never accessible to the subclass?
1. Public member
2. Protected member
3. Private member
4. All of the mentioned
28.What is the size of a class?
1. Sum of the size of all inherited variables along with the variables of the same class
2. The size of the class is the largest size of the variable of the same class
3. Classes in the programming languages do not have any size
4. Sum of the size of all the variables within a class.
29.Which class cannot create its instance?
1. Parent class
2. Nested class
3. Anonymous class
4. Abstract class
30.Encapsulation adds the function in a user-defined structure.
1. True
2. False
31.Which of the following variable violates the definition of encapsulation?
1. Array variables
2. Local variables
3. Global variables
4. Public variables
32.How can the concept of encapsulation be achieved in the program?
1. technique of combining more than one member functions into a single unit.
2. mechanism of combining more than one data member into a single unit.
3. mechanism of combining more than one data members and member functions that
implement on those data members into a single unit
4. technique of combining more than one data members and member functions into a single
unit, which can manipulate any data.
35.Which of the following statement of a program is not right?
1. class teacher{ }; teacher s[5];
2. class teacher{ }s;
3. class teacher{ }; teacher s;
4. class teacher{ }s[];
36.Which of the following syntax is incorrect for the class definition?
1. student class{ };
2. class student{ student(int a){} };
3. class teacher{ public: teacher(int a){ } };
4. None of the mentioned
37.The object cannot be________?
1. passed by copy
2. passed as function
3. passed by value
4. passed by reference
38.Which among the following feature does not come under the concept of OOPS?
1. Data binding
2. Data hiding
3. Platform independent
4. Message passing
39.Which of the following feature may be breaked if the user does not use the classes in the code?
1. Object must be used violated
2. Only the encapsulation concept is violated
3. Inheritance cannot be implemented
4. Basically, all the features of OOPS get violated
40.Which of the following feature interacts one object with another object?
1. Message reading
2. Message passing
3. Data transfer
4. Data binding
41.Which definition best defines the concept of abstraction?
1. Hides the important data
2. Hides the implementation and showing only the features
3. Hiding the implementation
4. Showing the important data
42.The combination of abstraction of the data and code is viewed in________.
1. Inheritance
2. Object
3. Class
4. Interfaces
43.The principle of abstraction___________
1. This class can access and manipulate all the private members of that class which connects
to a friend.
2. Friend class can only access and manipulate the protected data members of that class that
connects to a friend.
3. Friend class can't access any data member of another class but can use its methods
4. Friend class don't have any implementation
47.Consider the following Java program and select the right option from the given options.
class marksofstudent
int subjectmarks;
return &subjectmarks;
};
main()
marksofstudent s;
return 0;
1. It is the ability to process the many messages and data in one way
2. It is the ability to process the undefined messages or data in at least one way
3. It is the ability to process the message or data in more than one form
4. It is the ability to process the message or data in only one form
50.Which class/ or set of classes can describe the concept of polymorphism in the following code?
calculate_grade();
public : calculate_grade()
return 15;
};
public : calculate_grade()
return 30;
};
a) Andrea Ferro
b) Adele Goldberg
c) Alan Kay
d) Dennis Ritchie
a) Efficient Code
b) Code reusability
c) Modularity
d) Duplicate/Redundant data
3. Which was the first purely object oriented programming language developed?
a) Kotlin
b) SmallTalk
c) Java
d) C++
a) 1980’s
b) 1995
c) 1970’s
d) 1993
5. Which feature of OOP indicates code reusability?
a) Abstraction
b) Polymorphism
c) Encapsulation
d)Inheritance
b) stdlib.h
c) iostream.h
d) stdio.h
a) Data hiding
b) Message passing
c) Platform independent
d) Data binding
9. Which is the correct syntax of inheritance?
c) Polymorphism
d) Inheritance
11.The feature by which one object can interact with another object is _____________
a) Message reading
b) Message Passing
c) Data transfer
d) Data Binding
a) 4
b) 3
c) 2
d) 1
14.In multilevel inheritance, which is the most significant feature of OOP used?
a) Code efficiency
b) Code readability
c) Flexibility
d) Code reusability
a) It is a way of combining various data members and member functions that operate on those
b) It is a way of combining various data members and member functions into a single unit
c) It is feature of OOP
class A
int i;
A()
i=0; cout<<i;
A(int x=0)
i=x; cout<<I;
};
A obj1;
a) Parameterized constructor
b) Default constructor
a) Overloading &&
b) Overloading <<
c) Overloading ||
d) Overloading +=
20.In which access should a constructor be defined, so that object of the class can be created in any
function?
b) Private
c) Public
d) Protected
21.Which among the following is correct for the class defined below?
class student
{
int marks;
public: student(){}
student(int x)
{
marks=x;
}
};
main()
{
student s1(100);
student s2();
student s3=100;
return 0;
}
a) Program will give compile time error
23.Which constructor will be called from the object obj2 in the following C++ program?
class A
{
int i;
A()
{
i=0;
}
A(int x)
{
i=x+1;
}
A(int y, int x)
{
i=x+y;
}
};
A obj1(10);
A obj2(10,20);
A obj3;
a) A(int y, int x)
b) A(int y; int x)
c) A(int y)
d) A(int x)
24.Which among the following represents correct constructor?
a) –classname()
b) classname()
c) ()classname
d) ~classname()
a) Protected
b) Private
c) Public
d) Default
b) Dot operator
c) Arrow operator
a) Inheritance
b) Binding
c) Abstraction
d) Encapsulation
29.Which keyword among the following can be used to declare an array of objects in java?
a) allocate
b) arr
c) new
d) create
30.Which operator can be used to free the memory allocated for an object in C++?
a) Unallocate
b) Free()
c) Collect
d) delete
a) Properties
b) Names
c) Identity
d) Attributes
32.Which type of members can’t be accessed in derived classes of a base class?
b) Protected
c) Private
d) Public
a) Language independency
b) Multiple inheritance
c) Compile time
d) Runtime
c) Can’t be done
a) virt
b) virtually
c) virtual
d) anonymous
37.What happens if non static members are used in static member function?
a) Executes fine
d) Runtime error
a) Non-member functions which have access to all the members (including private) of a class
a) Cache
b) ROM
c) HDD
d) RAM
40.Which of the following best describes member function overriding?
b) Member functions having the same name and different signature inside main function
c) Member functions having the same name in base and derived classes
a) Polymorphism
b) Encapsulation
c) Abstraction
d) Inheritance
a) const
b) common
c) static
d) stat
a) *className objectName;
b) className* objectName;
c) className objectName();
d) className objectName;
46.Which class/set of classes can illustrate polymorphism in the following C++ code?
c) Class failed should also inherit class student for this code to work for polymorphism
d) All class student, topper and average together can show polymorphism
47.If data members are private, what can we do to access them from the class object?
a) Private data members can never be accessed from outside the class
50.If in multiple inheritance, class C inherits class B, and Class B inherits class A. In which
a) Parent class
b) Abstract class
c) Anonymous class
d) Nested class
52.___________ underlines the feature of Polymorphism in a class .
a) Virtual Function
b) Inline function
c) Enclosing class
d) Nested class
53.Which feature in OOP is used to allocate additional functions to a predefined operator in any
language?
a) Function Overloading
b) Function Overriding
c) Operator Overloading
d) Operator Overriding
a) Polymorphism
b) Overloading
c) Inheritance
d) Abstraction