How Well Do You Know Classes in C++?

Akela
3391
How Well Do You Know Classes in C++?
Class is a key notion in Object-Oriented programming and without knowledge about classes, you cannot create working programs in C++. Check your knowledge on the subject by answering our questions!

Class:

is a structure describing functions necessary for the working of a program

is user defined data describing an object and a method of working with it

is any user defined data

Object is:

a function working with a class

a variable

a substance having set values for properties and methods for working with them

What methods present in each class?

Input and output

Constructor and Destructor

No methods are obligatory

What is Constructor?

A special method, which is called for when creating a new object for automatical initialization of variables

A function, which creates a class instance

A class, which contains all methods necessary for work

What will happen if the user doesn't declare Constructor and Destructor in the class code?

Error

Class won't be accessible to the rest of the program

Constructor and Destructor will be represented implicitly

How to explicitly define Destructor correctly?

What value does Destructor return?

0/1

true/false

None

A code where Constructor is defined is shown in the picture. Did the user do it right?

Both Constructor and Desctructor should be defined in public, not private.

Yes

No

Choose the definition of polymorphism:

The first definition - polymorphism, the second - inheritance, the third- encapsulation.

a property of classes allowed to use the objects of classes with the same interface without information on the type and internal structure of the object

a property allowed to create a new derived class based on the existing one, given this, all characteristics of the existing class are assigned to the derived class

a property allowed to unite in a class both data and methods working with them and hide implementation details from the user

In what row is the MyClass class instance declared in this code?

Class instance is created in row 16

16

11

4

A programmer wrote a simple program shown in the picture but forgot to write a row, which displays the sum. What should be written in row 25?

cout

cout

cout

Choose the right statement for protected modifier

Private prohibits access beyond the class, public doesn’t restrict access at all, and protected allows only within the class and its derived classes

Methods and variables are accessible for usage both within the class and outside

Methods and variables are accessible for usage only within the class

Methods and variables are accessible for usage within the class, as well as in classes derived from this class

Can you declare a class without methods?

Yes

No

What is inheritance?

transmission of data to another class

a mechanism for creating a new class based on the existing one

a method of using a class in different programs

A code fragment where policeman class is declared is shown in the picture. What statement is right?

the policeman class is the derived class of the worker class

the worker class is a derived class from the policeman class

the worker class is a descendant of the policeman class

You have basic knowledge on the subject

You still have to know a lot about classes! Don't miss important details and carefully study all aspects: successful learning of this subject is a guarantee of successful writing of programs of different complexity in the future. Good luck! Show the quiz to friends and find know how well they know C++ classes!

You have intermediate knowledge on the subject

You're good at the basics, but you still don't know many things. Read books and articles, solve problems, try to write simple programs - only this way you can master the subject! Remember that you have nothing to do in Object Oriented programming without classes and pay sufficient attention to the topic. Good luck! Show the quiz to friends and find know how well they know C++ classes!

You know the subject in perfection!

You perfectly mastered the material and now you're good at classes. It's time to take on a new subject! You should repeat the material sometimes since classes are the basis of Object Oriented programming. Good luck! Show the quiz to friends and find know how well they know C++ classes!

Class:
1 / 15
Object is:
2 / 15
What methods present in each class?
3 / 15
What is Constructor?
4 / 15
What will happen if the user doesn't declare Constructor and Destructor in the class code?
5 / 15
How to explicitly define Destructor correctly?
6 / 15
What value does Destructor return?
7 / 15
A code where Constructor is defined is shown in the picture. Did the user do it right?
8 / 15
Choose the definition of polymorphism:
9 / 15
In what row is the MyClass class instance declared in this code?
10 / 15
A programmer wrote a simple program shown in the picture but forgot to write a row, which displays the sum. What should be written in row 25?
11 / 15
Choose the right statement for protected modifier
12 / 15
Can you declare a class without methods?
13 / 15
What is inheritance?
14 / 15
A code fragment where policeman class is declared is shown in the picture. What statement is right?
15 / 15

Calculating results...

Useful and short ads help us create new content every day.