Object Oriented Programming - Classes

6:  

Choose the correct statements from the following: 

A.

In a struct, the access control is public by default.

B.

In a class, the access control is private by default.

C.

In a class, the access control is public by default.

D.

Both (a) & (b)

 
 

Option: D

Explanation :

Click on Discuss to view users comments.

Write your comments here:



7:  

The fields in a class, of a C++ program are by default   

A.

protected

B.

public

C.

private

D.

none of the above

 
 

Option: C

Explanation :

Click on Discuss to view users comments.

Write your comments here:



8:  

Class A

{

int  i1;

protected :

int  i2;

public :

int i3;

}

class B : public A

{

public :

int i4;

};

class C :B

{

};

The variable i2 is accessible     

A.

to a public function in class A

B.

to a public function in cIa s s B

C.

to a public function in class C

D.

from the main function

 
 

Option: C

Explanation :

Click on Discuss to view users comments.

Write your comments here:



9:  

Class A

{

int  i1;

protected :

int  i2;

public :

int i3;

}

class B : public A

{

public :

int i4;

};

class C :B

{

};

Which varilible(s) is/are accessible from the main function?     

A.

i1

B.

i 2

C.

i 3

D.

None of the above

 
 

Option: D

Explanation :

Click on Discuss to view users comments.

reetikaa said: (10:03pm on Thursday 24th September 2015)
i think it shuld be i3 as it is accessible to all since it is public
Muhammad Ali said: (12:34am on Wednesday 28th February 2018)
i3 will be accessible from the main function as it is public

Write your comments here:



10:  

The following program
class abc;
class def
{
int i1 ;                        // statement 1
protected: int i2;   // statement 2
public: int i3;       //statement 3
friend abc;
} ;
class abc
{
public:
void main(def A)
{
cout << (A.i1=3);
cout <<  (A.i2=4);
cout << (A.i3=5);
}
} ;
void main( )
{
def x1 ;
abc x2 ;
x2.mn(x1);
}    

A.

will compile successfully if statement 1 is removed

B.

will compile successfully if statement 2 is removed

C.

will compile successfully if statement 3 is removed

D.

will run successfully and print 34 5

 
 

Option: D

Explanation :

Since abc is a friend of def, it can access all its data, does not matter whether it is declared private, protected or public.

Click on Discuss to view users comments.

Write your comments here:



Related MCQ


Syllabus covered in this section is-

  • O-O Programming Concepts , Class object instantiation
  • Inheritance, polymorphism and overloading
  • C++ Prograinming - Elements of C++, Tokens,
  • Identifters Variables and constants, data, types
  • Operators, Control, statements
  • Functions
  • Parameter passing
  • Class and objects
  •  Constructors and destructors
  •  Overloading,  Inheritance,
  • Templates, Exception handling

This Section covers OOPS Questions Answers .These questions can be used for the preparation of various competitive and academic exams like

  • UGC NET Computer Science
  • Pre PhD Entrance Exam
  • DOEACC Exams
  • Kendriya Vidyalaya Sangathan Entrance Test
  • Undergraduate Computer Science  Course
  • GATE Computer Science
  • Post Graduate Computer Science Exam
  •  PhD Entrance Exam
  • Computer Engineering

Who can benefit

  • Object Oriented Programming Questions Answers can be used by any student who is preparing for PhD entrance exam, pre PhD entrance exam, entrance exam  or any other such exam.
  • Any student who is preparing for DOEACC exams can also use OOPS questions answers for preparation of his exams.
  • OOPS mcq can be useful for the students who are pursuing any undergraduate or post graduate degree in computer science like BE, ME , Btech, Mtech, .BSc, MSc, BCA, MCA, BS, MS  or any other such degree
  • OOPS mcq with answers and explanation can also be useful for the students who are preparing for any competitive exam or recruitment exams like GATE Computer Science, UGC NET Computer Science, Kendriya Vidyalaya Sangathan PGT exam, PSU, IES or any other such exam.
  • OOPS multiple choice questions answers  can also be used by any candidate who wants to gain credits in OOPS in BS Computer science or MS Computer science,
  • You can download OOPS mcq pdf from this site.
  • You can get access to OOPS multiple choice questions answers EBook.

Various Search Terms Used For This Section Are

  • OOPS Quiz Questions With Answers

  • OOPS Exam Questions Answers

  • OOPS Mcq Questions Answers

  • OOPS Mcq Pdf Download

  • C++ Questions Answers

  • C++ Programming Questions Answers