Try new tool: URL Shortener

https://res.cloudinary.com/hg6hswtwo/image/upload/v1/media/pics/oop_toolsandjobs_se2jyx_cbpg1u
secondyear

OOP - Classes & Objects MCQs With Answers For Exams Part 4





OOP - Classes & Objects MCQs With Answers For Exams Part 4. This all questions helps in competative exams, placements exams and SPPU online exams 2020-21.

1 Which of the following functions are performed by a constructor?
A Construct a new class
B Construct a new object
C Construct a new function
D Initialize objects

Answer D

2 Which of the following ways are legal to access a class data member using this pointer?
A this->x
B this.x
C *this.x
D *this-x

Answer A

3 Which operator is having right to left associativity in the following?
A Array subscripting
B Function call
C Addition and subtraction
D Type cast

Answer D

4 Which operator is having the highest precedence?
A Postfix
B Unary
C Shift
D Equality

Answer A

5 #include <iostream>
 using namespace std;
 int main()
 {
 int a;
 a = 5 + 3 * 5;
 cout <<a;
 return 0;
 }
A 35
B 20
C 25
D 30
 

Answer B

6 #include <iostream>
 using namespace std;
 main()
 {
 double a = 21.09399;
 float b = 10.20;
 int c ,d;
 c = (int) a;
 d = (int) b;
 cout <<c <<' '<<d;
 return 0;
 }
A 20 10
B 10 21
C 21 10
D None

Answer A

7 #include <iostream>
 using namespace std;
 int main()
 {
 int num1 = 10;
 float num2 = 20;
 cout <<sizeof(num1 + num2);
 return 0;
 }
A 2
B 4
C 8
D Garbage

Answer B

8 #include <stdio.h>
 using namespace std;
 int array1[] = {1200, 200, 2300, 1230, 1543};
 int array2[] = {12, 14, 16, 18, 20};
 int temp, result = 0;
 int main()
 {
 for (temp = 0; temp <5; temp++) {
 result += array1[temp];
 }
 for (temp = 0; temp <4; temp++) {
 result += array2[temp];
 }
 cout <<result;
 return 0;
 }
A 6553
B 6533
C 6522
D 12200

Answer B

9 In procedural programming the focus in on …...........
A data
B structure
C function
D pointers

Answer C

10 In object oriented programming the focus is on ….......
A data
B structure
C function
D pointers

Answer A

11 Which of the following feature of procedure oriented program is false?
A Makes use of bottom up approach
B Functions share global data
C The most fundamental unit of program is function
D All of these

Answer A

12 Which of the following feature of object oriented program is false?
A Data and Functions can be added easily
B Data can be hidden from outside world
C Object can communicate with each other
D The focus is on procedures

Answer D

13 C++ was originally developed by ….......
A Donald Knuth
B Bjarne Sroustrups
C Dennis Ritchie
D None of these

Answer B

14 Which of the following approach is adopted in C++?
A Top down
B Bottom up
C Horizontal
D Vertical

Answer B

15 Which feature of C++ contain the concept of super class and subclass?
A Class and object
B Encapsulation
C Abstraction
D Inheritance
 

Answer D

16 The main intention of using inheritance is ….........
A to help in converting one data type to other
B to hide the details of base class
C to extend the capabilities of base class
D to help in modular programming

Answer C
  
17 If particular software can be used in some other application than the one
for which it is created then it reveals ….........
A data binding
B data reusability
C data encapsulation
D none of these

Answer B
  
18 Which of the following data type does not return anything?
A Int
B short
C long
D void

Answer D

19 How many objects can be created from an abstract class?
A Zero
B One
C Two
D As many as we want

Answer A

20 Which of the following statements is correct for a static member function?
 1. It can access only other static members of its class.
 It can be called using the class name, instead of objects
A Only 1 is correct
B Only 2 is correct
C Both 1 and 2 are correct
D Both 1 and 2 are incorrect

Answer C

21 Select the correct statement
I. In procedural programming oriented language all the function calls are
resolved at compile time.
II. In object oriented programming language all function calls are
resolved at compile time.
A Only I
B Only II
C Both I and II
D Neither I nor II

Answer A

 
22 What happens when a class with parameterized constructors and having no default
constructor is used in a program and we create an object that needs a zero-argument
constructor?
A Compile-time error
B Preprocessing error
C Runtime error
D Runtime exception

Answer A

23 Which of the following interface determines how your program will be used by other
program?
A Public
B Private
C Protected
D None of these

Answer A

24 What is the difference between struct and class in C++?
A All members of a structure are public and structures don't have constructors and destructors
B Members of a class are private by default and members of struct are public by default.
When deriving a struct from a class/struct, default access-specifier for a base class/struct
is public and when deriving a class, default access specifier is private.
C All members of a structure are public and structures don't have virtual functions
D All above

Answer B

25 Predict the output of following C++ program
#include<iostream>
using namespace std;

class Empty {};

int main()
{
 cout <<sizeof(Empty);
 return 0;
}
A A non zero value
B 0
C Compile time error
D Runtime error
 

Answer A

26 class Test {
 int x;
};
int main()
{
 Test t;
 cout <<t.x;
 return 0;
}
A 0
B Garbage value
C Compile time error

Answer C

27 Which of the following is true?
A All objects of a class share all data members of class
B Objects of a class do not share non-static members. Every object has its own copy
C Objects of a class do not share codes of non-static methods, they have their own copy
D None

Answer B

29 Which of the following is true about the following program
#include <iostream>
class Test
{
public:
 int i;
 void get();
};
void Test::get()
{
 std::cout <<"Enter the value of i: ";
 std::cin >>i;
}
Test t; // Global object
int main()
{
 Test t; // local object
 t.get();
 std::cout <<"value of i in local t: "<<t.i<<'\n';
 ::t.get();
 std::cout <<"value of i in global t: "<<::t.i<<'\n';
 return 0;
}
A Compiler Error: Cannot have two objects with same class name
B Compiler Error in Line "::t.get();"
C Compiles and runs fine

Answer C

30 Which of the following is true about new when compared with malloc. 1) new is an
operator, malloc is a function 2) new calls constructor, malloc doesn't 3) new returns
appropriate pointer, malloc returns void * and pointer needs to typecast to appropriate
type.
A 1 and 3
B 2 and 3
C 1 and 2
D All 1,2,3

Answer C

31 Predict the output?
#include <iostream>
using namespace std;
class Test
{
 int x;
 Test() { x = 5;}
};
int main()
{
 Test *t = new Test;
 cout <<t->x;
}
A Compile time error
B Garbage
C 0
D 5

Answer A
 





Publish Your Great Work

Your AD here