C++ (classes quiz) First Lecture

An illustration of a computer screen displaying C++ code, with visual elements representing classes and objects, vibrant colors, educational theme

C++ Class Fundamentals Quiz

Test your knowledge of C++ class concepts with our engaging quiz! From defining objects to understanding member functions, this quiz covers essential topics to help solidify your programming skills.

Features:

  • 11 challenging questions
  • Multiple choice format
  • Immediate feedback on your answers
11 Questions3 MinutesCreated by CodingNinja247
Name:
Q1/ How can you define the object of (Male) in the class (Human)?
Human male;
Human.male;
Male Human;
Male.human;
Q2/ It has been defined a variable of (name) inside the class (Human) and define an object (Male) so how can you enter the name inside the (Male) object
Cin << male.name;
Cin >> male.name;
Cin>> name.male;
Cin << name.male;
Q3/ Only one class can be defined in a program
Ture
False
Q4/ Only one object can be defined in each class
True
False
Q5/ By default setting the member function inside class without setting the identificer would be considered inside the
Private :
Public:
Protected:
None of these
Q6/ determine the output of the function below
#include<iostream.h>
 
class Empty {};
 
int main()
{
cout << sizeof(Empty);
return 0;
}
Non zero
Zero
Compile Error
None of above
Q7/ The error in this program is due to 
#include <stdio.h>
  
class Test {
    int x; // x is private
};
int main()
{
  Test t;
  t.x = 20; 
  getchar();
  return 0;
}
X is private
X is public
X is integer
None of above
Q8/ In the following program there is an error in compiling what is the error ??? 
class Rectangle {
int width, height;
public:
void set_values (int x, int y) {
width = x;
height = y;
}
int area()
{
return width*height;
}

int main () {
Rectangle rect;
rect.set_values (3,4);
cout << "Area of Rectangle: " << rect.area()<<endl;
return 0;
}
Return width*height
Int width, height;
}
};
Q9/ In the following program can the main function access the variable member redius ????  
#include<iostream>
using namespace std;   
class Circle
{
    public
        double radius;
          
        double  compute_area()
        {
            return 3.14*radius*radius;
        }     
};   
 
int main()
{
    Circle obj;
    obj.radius = 5.5;
    cout << "Radius is: " << obj.radius << "\n";
    cout << "Area is: " << obj.compute_area();
    return 0;
}
Yes
No
Q10/
Q9/ In the following program can the main function access the variable member redius ????  
#include<iostream>
using namespace std;   
class Circle
{
 double radius;
    public 
        double  compute_area()
        {
            return 3.14*radius*radius;
        }     
};   
 
int main()
{
    Circle obj;
    obj.radius = 5.5;
    cout << "Radius is: " << obj.radius << "\n";
    cout << "Area is: " << obj.compute_area();
    return 0;
}
Yes
No
{"name":"C++ (classes quiz) First Lecture", "url":"https://www.quiz-maker.com/QPREVIEW","txt":"Test your knowledge of C++ class concepts with our engaging quiz! From defining objects to understanding member functions, this quiz covers essential topics to help solidify your programming skills.Features:11 challenging questionsMultiple choice formatImmediate feedback on your answers","img":"https:/images/course8.png"}
Powered by: Quiz Maker