Wednesday 20 April 2016

C++ Classes Questions and Answers


1.  What does your class can hold?
A. data
B. functions
C. both a & b
D. none of the mentioned


Answer: Option C

Explanation:

The classes in c++ are used to manipulate both data and functions.


2.   How many specifiers are present in access specifiers in class?
A. 1
B. 2
C. 3
D. 4


Answer: Option C

Explanation:

There are three types of access specifiers. They are public, protected and private.



3.  How many kinds of classes are there in c++?
A. 1
B. 2
C. 3
D. 4


Answer: Option B

Explanation:

There are two kinds of classes in c++. They are absolute class and concrete class.



4.  Which is used to define the member of a class externally?
A. :
B. : :
C. #
D. none of the mentioned


Answer: Option B


5.  Which other keywords are also used to declare the class other than class?

A. struct
B. union
C. object
D. both a & b


Answer: Option D

Explanation:

Struct and union take the same definition of class but differs in the access techniques.


6. Which of the following is a valid class declaration?
A. class A { int x; };
B. class B { }
C. public class A { }
D. object A { int x; };


Answer: Option A


7. The fields in the class in c++ program are by default
A. protected
B. private
C. public
D. none of the mentioned


Answer: Option B


8. Constructors are used to
A. initalize the objects
B. construct the data members
C. both a & b
D. none of the mentioned


Answer: Option A

Explanation:

Once the object is declared means, the constructor are also declared by default.


9.  When struct is used instead of the keyword class means, what will happen in the program?
A. access is public by default
B. access is private by default
C. access is protected by default
D. none of the mentioned


Answer: Option A

10.  Which class is used to design the base class?
A. abstract class
B. derived class
C. base class
D. None of the mentioned


Answer: Option A


No comments:

Post a Comment