
C++ MCQ
Authored by Divya Kumawat
Education
1st - 5th Grade
10 Questions
Used 2+ times

AI Actions
Add similar questions
Adjust reading levels
Convert to real-world scenario
Translate activity
More...
Content View
Student View
1.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
The access specifier for members x of a class in C++?
class Sample {
int x;
};
public
private
protected
None of the above
2.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Consider the code below. What will it print?
class Demo {
public:
int a;
};
int main() {
Demo d;
d.a = 10;
std::cout << d.a;
return 0;
}
0
10
Garbage value
Compilation error
3.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What is the lifetime of a local object inside a function?
Entire program execution
Only until function exits
Until program ends
Until another object is created
4.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Which object is destroyed automatically at the end of program?
Local object
Static object inside function
Global object
Dynamic object
5.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What is the correct way to access a static member without creating an object?
Sample s; s.x;
Sample::x;
s.x;
static Sample::x;
6.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Which of the following is TRUE?
Static variable inside a class cannot be private
Static variable belongs to class, not object
Local objects persist throughout program
Global objects are destroyed after main
7.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What will be the output of this code?
#include <iostream>
class Test {
public:
Test() { std::cout << "Hello"; }
};
int main() {
static Test t;
}
Nothing
Hello
Hello Hello
Compilation error
Access all questions and much more by creating a free account
Create resources
Host any resource
Get auto-graded reports

Continue with Google

Continue with Email

Continue with Classlink

Continue with Clever
or continue with

Microsoft
%20(1).png)
Apple
Others
Already have an account?
Similar Resources on Wayground
14 questions
Operaciones con fracciones 6º
Quiz
•
5th - 7th Grade
10 questions
Kannada session - 8
Quiz
•
1st Grade
15 questions
Responsible Consumer
Quiz
•
3rd Grade - Professio...
10 questions
Tipos de Datos y Operadores Python
Quiz
•
1st Grade
10 questions
Session -10
Quiz
•
1st Grade
11 questions
phep chia phan so lop 4
Quiz
•
4th Grade
10 questions
I am dependable
Quiz
•
1st - 3rd Grade
10 questions
Hallway Expectations - Parkway Elementary
Quiz
•
KG - 3rd Grade
Popular Resources on Wayground
5 questions
This is not a...winter edition (Drawing game)
Quiz
•
1st - 5th Grade
25 questions
Multiplication Facts
Quiz
•
5th Grade
10 questions
Identify Iconic Christmas Movie Scenes
Interactive video
•
6th - 10th Grade
20 questions
Christmas Trivia
Quiz
•
6th - 8th Grade
18 questions
Kids Christmas Trivia
Quiz
•
KG - 5th Grade
11 questions
How well do you know your Christmas Characters?
Lesson
•
3rd Grade
14 questions
Christmas Trivia
Quiz
•
5th Grade
20 questions
How the Grinch Stole Christmas
Quiz
•
5th Grade