CJCoding With Joseph
15free / daySign inCreate account
TitleOpen
1
Output OperatorWhich operator is used for console output in C++?
easyNot startedPrintingSolve
3
Vector SizeWhat is the output of this code?
easyNot startedArraysSolve
5
Scope ResolutionWhat is the :: operator called in C++?
easyNot startedFunctionsSolve
6
Pointer BasicsWhich operator is used to get the memory address of a variable in C++?
easyNot startedPointersSolve
9
For Loop CountWhat is the output of this code?
easyNot startedLoopsSolve
10
String LengthWhat is the output of this code?
easyNot startedStringsSolve
12
Ternary OperatorWhat is the output of this code?
easyNot startedConditionalsSolve
13
Array Index OutputWhat is the output of this code?
easyNot startedArraysSolve
14
While Loop ConditionWhat is the output of this code?
easyNot startedLoopsSolve
16
Null PointerWhat keyword is used in modern C++ (C++11 and later) to represent a null pointer?
easyNot startedPointersSolve
19
String ConcatenationWhat is the output of this code?
easyNot startedStringsSolve
21
Unfreed Heap MemoryThis code compiles and runs, but it has a problem.
easyNot startedDynamic MemorySolve
22
Delete on Stack VariableThis code has a bug that causes undefined behavior.
easyNot startedDynamic MemorySolve
23
Dangling Pointer AccessThis code compiles but has a serious bug.
easyNot startedDynamic MemorySolve
24
Private Member in Base ClassThis code fails to compile.
easyNot startedInheritanceSolve
25
Default Private InheritanceThis code fails to compile at the indicated line.
easyNot startedInheritanceSolve
26
Missing Base Constructor CallThis code fails to compile.
easyNot startedInheritanceSolve
27
Non-Virtual Method CallThe programmer expects this code to print "Dog speaks", but it prints "Animal speaks" instead.
easyNot startedPolymorphismSolve
28
Cannot Create Abstract ObjectThis code fails to compile.
easyNot startedPolymorphismSolve
29
Missing DestructorThis code compiles and runs, but it has a problem.
easyNot startedRule of ThreeSolve
30
Default Copy Double FreeThis code compiles but crashes at runtime.
easyNot startedRule of ThreeSolve
41
Exception Handling KeywordsWhich three keywords are used for exception handling in C++?
easyNot startedExceptionsSolve
42
Code After throw Is SkippedWhat is the output of this code?
easyNot startedExceptionsSolve
43
Exception Header FileWhich header must you include to use std::runtime_error and std::invalid_argument in C++?
easyNot startedExceptionsSolve
44
Catch-All HandlerWhat does catch (...) do in a C++ exception handler?
easyNot startedExceptionsSolve
51
Template Type Parameter MeaningWhat does T represent in the following code?
easyNot startedTemplatesSolve
52
Template Class InstantiationWhich line correctly creates a Box<int> object given this template class?
easyNot startedTemplatesSolve
53
Valid Template Function SignatureWhich of the following is a valid C++ template function that returns the larger of two values?
easyNot startedTemplatesSolve
54
Template Function OutputWhat is the output of the following program?
easyNot startedTemplatesSolve
59
What Is a Stream?Which of the following best describes a "stream" in C++?
easyNot startedStreamsSolve
60
Input Stream ClassesWhich class should you use to read input from a file in C++?
easyNot startedStreamsSolve
61
Output Stream ClassesWhich class is used to write output to a file in C++?
easyNot startedStreamsSolve
62
Extraction Operator vs getlineWhat is a key difference between the extraction operator >> and getline() when reading a string from cin?
easyNot startedStreamsSolve
63
The get() FunctionWhat makes cin.get() different from the extraction operator cin >>?
easyNot startedStreamsSolve
64
setw ManipulatorWhat does setw(10) do when used with cout?
easyNot startedStreamsSolve
66
setprecision with fixedWhat is the output of the following code?
easyNot startedStreamsSolve
67
The ws ManipulatorWhat does the ws manipulator do when used with an input stream?
easyNot startedStreamsSolve
68
Stream Condition State: eof()Which of the following stream condition functions returns true when the stream has reached the end of input?
easyNot startedStreamsSolve
71
peek() vs unget()What does cin.peek() do?
easyNot startedStreamsSolve
72
Testing If a File Opened SuccessfullyAfter opening a file, which code correctly checks whether the file stream opened successfully?
easyNot startedStreamsSolve
73
Function Declaration vs DefinitionWhat is a function declaration (prototype) in C++?
easyNot startedFunctionsSolve
76
What Is a C-String?Which of the following correctly describes a C-string in C++?
easyNot startedStringsSolve
77
Character Classification FunctionsWhich function from <cctype> returns true if a character is a letter of the alphabet?
easyNot startedStringsSolve
79
find Returns nposWhat does s.find("xyz") return when "xyz" is not found in the string s?
easyNot startedStringsSolve
81
What Is std::string?Which description best fits std::string in C++?
easyNot startedSTL ContainersSolve
82
String Iterator Type and AccessWhich statement about std::string iteration and element access is correct?
easyNot startedSTL ContainersSolve
83
What Type Does std::string Store?What element type does std::string store, and can it store arbitrary types like std::vector can?
easyNot startedSTL ContainersSolve
84
What Is std::vector?Which description best fits std::vector<T>?
easyNot startedSTL ContainersSolve
86
Vector Iterator TypeWhat category of iterator does std::vector provide, and what operations does it support?
easyNot startedSTL ContainersSolve
88
Deque vs Vector: Key AdvantageWhat does std::deque offer that std::vector does not?
easyNot startedSTL ContainersSolve
89
Deque Subscript and Random AccessDoes std::deque support the subscript operator [] and random access iterators?
easyNot startedSTL ContainersSolve
90
How std::list Stores ElementsHow does std::list<T> store its elements in memory?
easyNot startedSTL ContainersSolve
92
Does std::list Support []?Can you use the subscript operator [] to access elements in std::list?
easyNot startedSTL ContainersSolve
94
What Makes std::set Unique?Which two properties always hold for std::set<T>?
easyNot startedSTL ContainersSolve
95
Accessing Elements in std::setHow do you check whether a value exists in a std::set, and why is the [] operator not available?
easyNot startedSTL ContainersSolve
97
Does std::set Store Pairs?Does std::set store pair objects, or does each element hold a single value?
easyNot startedSTL ContainersSolve
98
What Is std::map?Which description best fits std::map<Key, Value>?
easyNot startedSTL ContainersSolve
101
Map Sorted by KeyIn what order does iterating over a std::map visit its entries?
easyNot startedSTL ContainersSolve
104
Which Containers Auto-Sort?Which STL containers automatically maintain their elements in sorted order at all times?
easyNot startedSTL ContainersSolve
106
Read-Only IteratorsWhich iterator type provides read-only access and prevents modification of container elements at compile time?
easyNot startedSTL ContainersSolve
107
Iterator Dereference OperatorWhich operator is used to access the element that an STL iterator currently points to?
easyNot startedSTL ContainersSolve
108
Which Containers Store Unique Values?Which STL containers automatically reject duplicate values or keys?
easyNot startedSTL ContainersSolve
109
Do STL Containers Auto-Resize?Which statement about memory management in standard STL containers is correct?
easyNot startedSTL ContainersSolve
112
class or typename in the Template PrefixThis template is written with class T instead of typename T, and it is called with an int and then a char.
easyNot startedTemplatesSolve
113
Deducing T From a VectorprintFirst receives a whole vector of strings.
easyNot startedTemplatesSolve
114
Choosing the Type YourselfThe call writes the template argument explicitly: larger<double>(3, 4.5).
easyNot startedTemplatesSolve
115
Two Arguments That Disagree About TThis program does not compile.
easyNot startedTemplatesSolve
116
Pair<int, double> Versus Pair<double, int>Both objects are made from the same class template.
easyNot startedTemplatesSolve
117easyNot startedTemplatesSolve
118
decltype and Integer Divisiondecltype gives each variable the type of the expression inside the brackets.
easyNot startedTemplatesSolve
132
Why Catch by const ReferenceThe handler is written as catch (const std::exception& e).
easyNot startedExceptionsSolve
133
The Correct what() OverrideEmptyCartError derives from std::exception and wants its own message.
easyNot startedExceptionsSolve
134
Which Family invalid_argument Belongs ToA std::invalid_argument is thrown and there are two handlers.
easyNot startedExceptionsSolve
135
Which Call Throwsdoubled throws for a negative number.
easyNot startedExceptionsSolve
136
vector::at Versus operator[]scores has three elements.
easyNot startedExceptionsSolve
137
What stoi Throwsstd::stoi is called with a normal number, with text, and with a number far too large for an int.
easyNot startedExceptionsSolve
138
No finally Keyword in C++C++ has no finally keyword.
easyNot startedExceptionsSolve
139
The Type of a Thrown String Literalthrow "disk full"; throws a string literal.
easyNot startedExceptionsSolve
140
What new Throws When Memory Runs OutWhen new cannot get the memory it was asked for, which exception does it throw, and would this handler catch it?
easyNot startedExceptionsSolve
141
A Loop That Catches and ContinuesThe try/catch sits INSIDE the loop body.
easyNot startedExceptionsSolve
2
Reference vs CopyWhat is the output of this code?
mediumNot startedVariablesSolve
4
Class ConstructorWhat is the output of this code?
mediumNot startedClassesSolve
7
Pointer Dereference OutputWhat is the output of this code?
mediumNot startedPointersSolve
8
Inheritance AccessWhich access specifier allows a derived class to access a member, but keeps it hidden from code outside the class hierarchy?
mediumNot startedClassesSolve
11
Default Function ArgumentWhat is the output of this code?
mediumNot startedFunctionsSolve
15
Function OverloadingWhat is the output of this code?
mediumNot startedFunctionsSolve
17
Increment OperatorsWhat is the output of this code?
mediumNot startedVariablesSolve
31
Wrong Delete on ArrayThis code has a subtle bug.
mediumNot startedDynamic MemorySolve
32
Pointer to Local VariableThis code compiles with a warning but produces unpredictable output.
mediumNot startedDynamic MemorySolve
33
Missing Assignment OperatorThis class has a destructor and copy constructor, but the code still crashes.
mediumNot startedRule of ThreeSolve
34
Shallow Copy BugThis code crashes when the objects are destroyed.
mediumNot startedRule of ThreeSolve
35
Rule of Three ViolationThis class manages dynamic memory.
mediumNot startedRule of ThreeSolve
36
Object SlicingThe programmer expects this to print "Cat meows", but it prints "Animal speaks" instead.
mediumNot startedPolymorphismSolve
37
Non-Virtual Destructor LeakThis code has a subtle bug when delete base runs.
mediumNot startedPolymorphismSolve
38
Method Hiding in Derived ClassThis code fails to compile on the marked lines.
mediumNot startedInheritanceSolve
39
Diamond Inheritance AmbiguityThis code fails to compile.
mediumNot startedInheritanceSolve
40
Accidental Method Signature MismatchThe programmer expects this to print "Derived: 42", but it prints "Base: 42" instead.
mediumNot startedPolymorphismSolve
45
The noexcept SpecifierWhat does the noexcept specifier do when added to a function declaration in C++?
mediumNot startedExceptionsSolve
46
Catch Block OrderingThis code has a problem related to the order of catch blocks.
mediumNot startedExceptionsSolve
47
Catch by Value Causes SlicingWhat is the output of this code?
mediumNot startedExceptionsSolve
48
Bare throw RethrowsWhat is the output of this code?
mediumNot startedExceptionsSolve
49
Exception Thrown in ConstructorWhat is the output of this code?
mediumNot startedExceptionsSolve
50
Unhandled Exception BehaviorWhat happens when a C++ program throws an exception that is never caught by any catch block?
mediumNot startedExceptionsSolve
55
Template Type DeductionWhat is the output of this code?
mediumNot startedTemplatesSolve
56
Two-Type Template Class OutputWhat is the output of this code?
mediumNot startedTemplatesSolve
57
Template with Two Type ArgumentsWhat is the output of the following program?
mediumNot startedTemplatesSolve
58
Template Instantiation FailureThe following code fails to compile at the call site.
mediumNot startedTemplatesSolve
65
setfill OutputWhat is the output of the following code?
mediumNot startedStreamsSolve
69
seekg and tellgAn ifstream has an internal get position tracking the next character to read.
mediumNot startedStreamsSolve
70
Stream Go TestWhich loop is the correct idiomatic "go test" for reading integers from a stream until it fails or reaches end-of-file?
mediumNot startedStreamsSolve
74
const Reference ParameterWhy would you declare a function parameter as const string& rather than just string?
mediumNot startedFunctionsSolve
75
Base Class as Function ParameterWhat is the advantage of writing a function with a base class reference parameter, such as:
mediumNot startedFunctionsSolve
78
substr ParametersWhat does s.substr(2, 4) return when s = "Hello World"?
mediumNot startedStringsSolve
80
stoi Stops at Non-DigitWhat does stoi("42abc") return in C++?
mediumNot startedStringsSolve
85
Vector Insertion PerformanceWhich insertion operation on std::vector runs in O(1) amortized time, and why is inserting at the front slow?
mediumNot startedSTL ContainersSolve
87
How Deque Stores ElementsHow does std::deque store its elements internally, and how does this differ from std::vector?
mediumNot startedSTL ContainersSolve
91
List Iterator TypeWhat type of iterator does std::list provide, and what limitation does this create?
mediumNot startedSTL ContainersSolve
93
List Insertion SpeedWhat is the time complexity of inserting an element into the middle of a std::list once you have an iterator to the desired position?
mediumNot startedSTL ContainersSolve
96
Set Iterator Type and Read-Only AccessWhat type of iterator does std::set provide, and can you modify elements through it?
mediumNot startedSTL ContainersSolve
99
Map Subscript Operator BehaviorWhat does map[key] do if the key does not already exist in the map?
mediumNot startedSTL ContainersSolve
100
Map Iterator Dereference TypeWhen you dereference a std::map<string, int> iterator, what type do you get?
mediumNot startedSTL ContainersSolve
102
Inserting a Duplicate Key in std::mapWhat happens when you call map.insert({"age", 30}) and the key "age" already exists with value 25?
mediumNot startedSTL ContainersSolve
103
Which Containers Use Contiguous Memory?Which standard STL containers guarantee that all elements are stored in a single contiguous block of memory?
mediumNot startedSTL ContainersSolve
105
Which Containers Support Random Access Iterators?Which STL containers provide random access iterators that support +n and -n arithmetic in O(1)?
mediumNot startedSTL ContainersSolve
110
Which Destructor Fits the Relationship?Both classes manage a dynamically allocated array of const Part.
mediumNot startedPointersSolve
111
Copying an AggregationPickList keeps the addresses of Part objects it does not own in a const Part m_parts array that it allocated with new[], together with size_t m_count.
mediumNot startedPointersSolve
119
Three Types in One Function CallThis function template has three type parameters and is called as describe(7, 'q', 1.5).
mediumNot startedTemplatesSolve
120
Trailing Return Type With decltypeThe return type is written after the arrow: -> decltype(a + b).
mediumNot startedTemplatesSolve
121
When the Compiler Cannot Deduce TT appears only in the return type of zero, and the function takes no arguments.
mediumNot startedTemplatesSolve
122
A Size as a Template ParameterN is a non-type template parameter: a value instead of a type.
mediumNot startedTemplatesSolve
123
A Default Template Argument Fills the GapTriple has three type parameters, but the object is created with only two: Triple<int, std::string>.
mediumNot startedTemplatesSolve
124
Defining get() Outside the Class Templateget() is declared inside Box but will be defined outside the class body, where the comment is.
mediumNot startedTemplatesSolve
125
Which identify Overload RunsTwo overloads of identify exist: one takes T&, the other takes T&&.
mediumNot startedTemplatesSolve
126
Why swapValues(x, 5) Will Not CompileswapValues(x, y) works and prints 2 1, but the program fails to compile because of swapValues(x, 5).
mediumNot startedTemplatesSolve
142
throw e Versus a Bare throwBoth functions catch a DerivedError through a const BaseError&.
mediumNot startedExceptionsSolve
143
A try Without a catchThe try block has no handler after it.
mediumNot startedExceptionsSolve
144
The Base Handler Comes FirstA std::runtime_error is thrown, and the handler for std::exception is written BEFORE the handler for std::runtime_error.
mediumNot startedExceptionsSolve
145
Guards Closing During UnwindingEach function owns a Guard that prints when it is built and when it is destroyed.
mediumNot startedExceptionsSolve
146
Destroyed Once or TwiceThe second Sensor throws from its constructor.
mediumNot startedExceptionsSolve
147
The Member Built Before the ThrowMachine has a Part member and its constructor throws after the body starts.
mediumNot startedExceptionsSolve
148
A return That Is Never Reachedshare has a return inside its try block and another inside its catch block.
mediumNot startedExceptionsSolve
149
Inheriting runtime_error's ConstructorConfigError declares no constructor of its own, only a using-declaration.
mediumNot startedExceptionsSolve
150
Why m_text.c_str() Is Safe in what()what() returns m_text.c_str().
mediumNot startedExceptionsSolve
151
Handler Order for Three LevelsDbError derives from AppError, which derives from std::runtime_error.
mediumNot startedExceptionsSolve
152
Nested try With a RethrowThe inner handler prints a line and then rethrows with a bare throw;.
mediumNot startedExceptionsSolve
153
Check First or Catch LaterBoth halves print the same words for index 7.
mediumNot startedExceptionsSolve
18
Virtual Function ConceptWhat is the purpose of the virtual keyword when used on a method in a base class?
hardNot startedClassesSolve
20
Static Class MemberWhat is the output of this code?
hardNot startedClassesSolve
127
A Named Rvalue Reference Is Still an Lvalueinspect receives the literal 7 through an rvalue reference named value.
hardNot startedTemplatesSolve
128
One Counter per SpecializationEach Counter<T> has a static member made that its constructor increments.
hardNot startedTemplatesSolve
129
The Error That Waits for InstantiationWithout the larger(p, q) line the program compiles and prints 9.
hardNot startedTemplatesSolve
130
decltype(x) Versus decltype((x))a is declared with decltype(x) and b with decltype((x)), the same variable with an extra pair of brackets.
hardNot startedTemplatesSolve
131
Returning a Copy or a Reference From Boxget() returns T by value and peek() returns const T&.
hardNot startedTemplatesSolve
154
What a Return Code Cannot CarrydivideCode signals an error by returning -1; divideThrow throws instead.
hardNot startedExceptionsSolve
155
An Exception Crosses Three Functionsmain calls level1, which calls level2, which calls level3, and level3 throws.
hardNot startedExceptionsSolve
156
A noexcept Function That Throws Anywayreport() is marked noexcept but throws.
hardNot startedExceptionsSolve
157hardNot startedExceptionsSolve
158
Where catch(...) Has to GoAs written, catch (...) is the LAST handler and the program prints runtime: disk and then something else.
hardNot startedExceptionsSolve
159
A what() Built From a Code and a MessageHttpError stores a code and builds its full text in the constructor.
hardNot startedExceptionsSolve
160
A Bare throw With Nothing to Rethrowretry() executes a bare throw; while NO exception is being handled.
hardNot startedExceptionsSolve
161
A Throw Inside a catch BlockThe handler inside convert prints a line and then throws a NEW std::runtime_error.
hardNot startedExceptionsSolve