Oops Imp Questions and SQL Query
Oops Imp Questions and SQL Query
Multiple
Multilevel
Distributive
Hierarchical
Answer: Distributive
{}
Multilevel
Multiple
Hybrid
Hierarchical
Answer:
The given OOP code is an example of Multiple inheritance.
Q3. In OOP, which of the following functions throws an error when a class is
inherited?
Public
Private
Protected
Friend
Answer:
Q4. In OOP which concept allows a class object to be used inside another
class?
Inheritance
Composition
Abstraction
Encapsulation
Answer:
The concept of using objects of one class into another class is known as
Composition.
Q5. Which of the following provides a programmer with the facility of using
object of a class inside other classes?
Inheritance
Composition
Abstraction
Encapsulation
Answer:
The concept of using objects of one class into another class is known as
Composition.
Friend constructor
Copy constructor
Default constructor
Parameterized constructor
Answer:
Friend function is not a constructor whereas others are a type of constructor used
for object initialization. So correct option is Friend constructor.
Q7. Which of the following class allows to declare only one object of it?
Abstract class
Virtual class
Singleton class
Friend class
Answer:
Singleton class allows the programmer to declare only one object of it, If one tries to
declare more than one object the program results into error.
Q8. In OOP which of the following function is given the same access as
methods to private and protected data of a class ?
Answer:
member variable
member function
class variable
class function
Answer:
Q10. In OOP which of the following is true when a derived class inherits a
base class privately ?
Public members of the base class become private members of the derived class.
Private members of the base class are not inherited.
Protected members of the base class become private members of the derived
class.
All of these.
Answer:
All of these.
Explanation:
Private members of the base class are not inherited: Private members of
a base class are never accessible directly by derived classes.
So, all the statements are true in the context of private inheritance.
Q11. In OOP, which of the following is a synonym for function overloading ?
Virtual polymorphism
Transient polymorphism
Ad-hoc polymorphism
Pseudo polymorphism
Statement (I): The friend function and the member functions of a friend
class directly access the private and protected data.
Statement (II): The friend function can access the private data through the
member functions of the base class.
In the light of the above statements, choose the most appropriate answer
from the options given below:
Q13. In OOP, which of these helps the compiler process objects differently
based on their data type or class?
Inheritance
Polymorphism
Abstraction
Encapsulation
Answer: Polymorphism
Answer:
Explanation: C++ does not allow a derived class pointer to point a base class
pointer whereas Base class can point to a derived class object. Both base class and
derived class can have pointer objects.
Static function
Friend function
Constant function
Virtual function
Function
Class
Object
Operator function
Answer: Object
Explanation: Objects of any class cannot be made a friend of any other or same
class whereas functions, classes and operator functions can be made a friend.
Q17. How many types of polymorphism are there in C++ , Java or Python ?
Answer: There are Two types of polymorphism in C++, Java or Python namely
Run-Time and Compile-Time Polymorphisms.
Answer: Class
Q23. Which of the following approach is used by an OOP language like C++?
a) Top-down b) Bottom-up
c) Left-right d) Right-left
Answer: Bottom-up
Answer: Top-down
Answer: A,B->C
SQL QUERY
Q1.
Answer: `
FROM (
FROM Sales
GROUP BY SalesPerson
) AS Sales_Avg;