0% found this document useful (0 votes)
81 views9 pages

Oops Imp Questions and SQL Query

Few Imp questions of oops and sql

Uploaded by

rayalbeast1000
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
81 views9 pages

Oops Imp Questions and SQL Query

Few Imp questions of oops and sql

Uploaded by

rayalbeast1000
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 9

Q1. In OOP, which of the following is not a type of inheritance?

 Multiple

 Multilevel

 Distributive

 Hierarchical

Answer: Distributive

Q2. The following OOP code is an example of ___________ inheritance.

class M : public N, public P

{}

 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:

Private functions throw an error when a class is inherited.

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.

Q6. Which of the following is not a type of Constructor?

 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:

In Object-Oriented Programming (OOP), a Friend function is given the same access


as methods to the private and protected data of a class.
A friend function is a function that is not a member of a class but has access to its
private and protected members. This concept is primarily used in C++.

Q9. In OOP which of these is a function defined in a class ?

 member variable
 member function
 class variable
 class function

Answer:

In Object-Oriented Programming (OOP), a function defined in a class is called a


Member Function.

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:

 Public members of the base class become private members of the


derived class: When inheritance is private, all public and protected members
of the base class become private members of the derived class.

 Private members of the base class are not inherited: Private members of
a base class are never accessible directly by derived classes.

 Protected members of the base class become private members of the


derived class: Similarly, protected members of the base class become private
members of the derived class when inheritance is private.

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

Answer: Ad-hoc polymorphism

Explanation: Function overloading is a form of polymorphism where multiple


functions can have the same name but different parameters. This type of
polymorphism is known as ad-hoc polymorphism. Ad-hoc polymorphism allows
functions to be applied to arguments of different types.

Q12. Given below are two statements:

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:

 Both Statement I and Statement II are correct


 Both Statement I and Statement II are incorrect
 Statement I is correct but Statement II is incorrect
 Statement I is incorrect but Statement II is correct

Answer: Both Statement I and Statement II are correct

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

Q14. Which of the following is correct?

 Base class pointer object cannot point to a derived class object


 Derived class pointer object cannot point to a base class object
 A derived class cannot have pointer objects
 A base class cannot have pointer objects

Answer:

Derived class pointer object cannot point to a base class object

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.

Q15. Out of the following, which is not a member of the class?

 Static function
 Friend function
 Constant function
 Virtual function

Answer: Friend function


Explanation: Friend function is not a member of the class. They are given the same
access rights as the class member function have but they are not actual members of
the class.

Q16. Which of the following cannot be a friend?

 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.

Q18. How run-time polymorphisms are implemented in C++?


a) Using Inheritance
b) Using Virtual functions
c) Using Templates
d) Using Inheritance and Virtual functions

Answer: Run-time polymorphism is implemented using Inheritance and Virtual


Functions in which object decides which function to call.

Q19. How compile-time polymorphisms are implemented in C++?


a) Using Inheritance
b) Using Virtual functions
c) Using Templates
d) Using Inheritance and Virtual functions

Answer: Compile-time polymorphism is implemented using Templates in which


the types (which can be checked during compile-time) are used decides which
function to be called.

Q20. Which of the following is an abstract data type?


a) int
b) float
c) class
d) string

Answer: Class

Q21. Which concept means the addition of new components to a program as


it runs?
a) Data hiding
b) Dynamic binding
c) Dynamic loading
d) Dynamic typing

Answer: Dynamic loading


Q22. Which of the following explains the overloading of functions?
a) Virtual polymorphism b)
Transient polymorphism
c) Ad-hoc polymorphism d)
Pseudo polymorphism

Answer: Ad-hoc polymorphism

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

Q24. Which of the following approach is used by an Structural Programming


language ?
a) Top-down b) Bottom-up
c) Left-right d) Right-left

Answer: Top-down

Q25. How structures and classes in C++ differ?


a) In Structures, members are public by default whereas, in Classes, they are private
by default
b) In Structures, members are private by default whereas, in Classes, they are public
by default
c) Structures by default hide every member whereas classes do not
d) Structures cannot have private members whereas classes can have

Answer: In Structures, members are public by default whereas, in


Classes, they are private by default

Q26. Which of the following shows multiple inheritances?


a) A->B->C b) A->B; A->C
c) A,B->C d) B->A

Answer: A,B->C

Q27. What does modularity mean?


a) Hiding part of program
b) Subdividing program into small independent parts
c) Overriding parts of program
d) Wrapping things into single unit

Answer: Subdividing program into small independent parts

Explanation: Modularity means dividing a program into independent sub


programs so that it can be invoked from other parts of the same program or any other
program.

Q28. What happens if a class does not have a name?

(a) It will not have a constructor

(b) It will not have a destructor

(c) It is not allowed

(d) It will neither have a constructor or destructor

Answer: ` It will not have a destructor

SQL QUERY

Q1.
Answer: `

SELECT MAX(avg_sales) AS max_total_sale

FROM (

SELECT SalesPerson, AVG(TotalSale) AS avg_sales

FROM Sales

GROUP BY SalesPerson

) AS Sales_Avg;

You might also like