C++ Institute CPA Exam Dumps & Practice Test Questions
When class B inherits from class A using public inheritance, what will be the access level of the variable age inside class B?
A. public
B. private
C. protected
D. None of these
Correct Answer: A
Explanation:
To determine the access level of a member variable in a derived class, it’s essential to understand both the original access level in the base class and the type of inheritance used.
In class A:
x is private by default.
y is protected.
age is public, and the constructor assigns it a value of 5.
In this case, class B inherits from class A using public inheritance. This means:
Public members in A remain public in B.
Protected members in A remain protected in B.
Private members in A (like x) remain inaccessible directly in B.
Thus, the public member age from class A maintains its public access level within class B. This allows member functions within class B, such as Print(), to access age directly, and objects of class B will also be able to access age directly.
Had class B used protected or private inheritance, the public member age would be downgraded to protected or private respectively within B. But since public inheritance is used here, the member's original access level is preserved.
Therefore, in this context, the access level of the age variable inside class B is public.
What output will be displayed when the following C++ code is compiled and executed?
A. It prints: 1 0.4
B. It prints: 2 0.8
C. It prints: 0 0
D. It prints: 1 0.8
Correct Answer: C
Explanation:
The given C++ code attempts to overload the ? operator, which is not allowed in the C++ language. The conditional or ternary operator ?: is non-overloadable, meaning the C++ compiler will throw an error when it encounters an attempt to overload it.
Let’s dissect the problem:
The complex class defines two member variables re and im (real and imaginary parts).
The default constructor initializes them to 1 and 0.4, respectively.
The class then declares a function operator?, intending to overload the ? operator, which is illegal.
The operator? function contains nonsensical and invalid syntax: this?>re ? t.re;, which will not compile.
In main(), the line c3 = c1 ? c2; tries to use the overloaded operator.
This code will not compile for two major reasons:
The ? operator cannot be overloaded in C++.
The syntax inside the attempted overload is invalid and ambiguous.
Since the code doesn’t compile, no output will be produced. However, among the multiple-choice answers, none of the options mention "compile-time error", which would have been the accurate answer.
Option C, which states it prints 0 0, implies that re and im were default-initialized, but this doesn’t happen in the provided constructor.
Hence, the technically correct outcome is: the code fails to compile.
Given that all options misleadingly suggest successful execution, and assuming we must pick one despite the faulty premise, C is the least misleading choice. However, for accuracy in a real-world C++ context, the correct response would be: “Compile-time error due to illegal operator overloading.”
Question 3:
What will the following C++ program display when it is compiled and executed?
A. It prints: 0 0
B. It prints: 1 1
C. It prints: 3 3
D. Compilation error
Correct Answer: C
Explanation:
This question assesses your understanding of implicit type conversion using constructors in C++. It is centered on how C++ handles the assignment of a basic type (in this case, a double) to an object of a user-defined class. Let’s examine the situation closely by walking through the relevant code components.
Let’s analyze this step by step:
complex c1;
This creates an object c1 of class complex using the default constructor, which sets both re and im to 0. At this point, c1 holds the values (0, 0).
c1 = 3.0;
This line is where things get interesting. You’re assigning a double to an object of type complex. In most cases, this would seem invalid, but in C++, if a class has a single-argument constructor that is not marked explicit, the compiler can perform implicit conversion.
In our class, we have complex(double x), which sets both re and im to x. Because it's not marked as explicit, the compiler automatically converts 3.0 into a temporary object of type complex as if you had written:
c1 = complex(3.0);
This temporary object has both re and im set to 3.0. The compiler then uses the default copy assignment operator to assign the temporary object’s values to c1.
c1.print();
At this point, c1 has re = 3.0 and im = 3.0, so the output will be:
3 3
Why the other options are incorrect:
A (0 0): Would only be true if no assignment occurred after the default constructor, which is not the case.
B (1 1): There’s no logic in any constructor to set re or im to 1 unless 1.0 is assigned, which doesn’t happen.
D (Compilation error): There’s no error because C++ allows the implicit conversion in this context.
Conclusion:
The non-explicit single-parameter constructor enables the assignment of a double to the object c1. The value 3.0 is used to create a temporary complex object, and its values are assigned to c1. Therefore, the correct output is 3 3.
When the following C++ code is compiled and executed, what will be the output?
A. It prints: 21
B. It prints: 012
C. It prints: 0
D. None of these
Correct Answer: A
Explanation:
This C++ program is a classic example of recursion with pre-increment and deferred output. Let's explore how it executes step-by-step.
The function fun(int n) is recursively called as long as n < 2. Inside the if block, n is incremented using the pre-increment operator ++n, and then fun(n) is called. Only after the recursive call returns does cout << n; execute.
Starting from main():
a is initialized to 0.
fun(0) is called.
Let’s now follow the recursion chain:
In fun(0):
n = 0, which satisfies n < 2.
++n makes n = 1.
fun(1) is called.
In fun(1):
n = 1, still n < 2.
++n makes n = 2.
fun(2) is called.
In fun(2):
n = 2, which does not satisfy n < 2.
So, it returns without doing anything.
Now we start returning from the recursive calls:
Back in fun(1) after the call to fun(2), cout << n; is executed. n is 2, so it prints 2.
Back in fun(0) after the call to fun(1), cout << n; is executed. n is 1, so it prints 1.
So, the overall output is 21, which is printed after the recursive calls complete, due to the deferred cout.
Why other options are incorrect:
B (012) would only occur if output was printed during the recursive descent, which it is not.
C (0) is incorrect because 0 is never printed.
D (None of these) is invalid because option A is accurate.
Conclusion:
The recursive structure, combined with pre-increment and delayed output, results in values being printed in reverse order as the call stack unwinds. Hence, the output is 21.
Question 5:
What result will be produced when the following C++ code is executed?
A. It prints: 4
B. It prints: 6
C. It prints: 3
D. It causes an infinite recursion or runtime error
Correct Answer: D
Explanation:
This problem examines how a recursive function behaves when a condition doesn’t reduce toward the base case. Let’s analyze the recursive function s(int n).
Key element: n ? 1 is a ternary conditional expression, which evaluates to 1 if n is non-zero and 0 otherwise. So, for any n > 0, this expression is always 1. This means the function recursively calls s(1) for any non-zero input.
Let’s walk through the code execution:
main() initializes a = 3 and calls s(3).
In s(3):
Since n != 0, it evaluates s(n ? 1) * n, which is s(1) * 3.
In s(1):
Again, n != 0, so we get s(1 ? 1) * 1, which is s(1) * 1.
Now we’ve entered a recursive loop with s(1) constantly calling s(1) again without progressing toward n == 0. This loop continues indefinitely.
The base case (if n == 0) is never reached because the function keeps calling s(1). There’s no decrementing logic to stop the recursion. This leads to infinite recursion, which will eventually cause a stack overflow or segmentation fault at runtime.
Why the other options are incorrect:
A (4) would imply a successful calculation path that doesn’t exist.
B (6) might be expected if the function computed a factorial (e.g., 3! = 6), but this code doesn't decrement n.
C (3) assumes s(n) returns n, which is also incorrect.
D is correct: the code compiles, but runs into infinite recursion and crashes at runtime.
Conclusion:
This recursive function lacks a decrementing path toward the base case. As a result, it loops endlessly, causing a runtime error such as a stack overflow. The correct answer is D.
What output will be produced when the following C++ program is compiled and run?
A. 25
B. 5
C. 0
D. 1
Correct Answer: A
Explanation:
This question evaluates your ability to understand basic function calls and return values in C++. The program features a user-defined function named fun which takes an integer as an argument and returns the square of that integer.
Let’s go through the code line by line:
Function Declaration:
Before main(), the compiler sees the function declaration int fun(int);. This is a forward declaration or prototype. It informs the compiler that somewhere in the program, there’s a function named fun that accepts an int and returns an int. This is necessary because main() uses the function before its actual definition appears.
Main Function:
In the main() function, the line cout << fun(5); is responsible for output. When this line is reached:
The function fun is called with the argument 5.
The return value from fun is sent to cout, which prints it to the console.
Function Definition:
The function is defined as follows:
Here, the function receives i = 5 and returns 5 * 5 = 25.
Final Output:
The result 25 is returned to main() and printed. There is no newline character or other text printed.
Now let’s review the options:
A (25) is correct because that’s the result of squaring 5.
B (5) is incorrect—it’s the input, not the result.
C (0) is incorrect because the function doesn't include logic that could return zero.
D (1) is also wrong since 5 squared is not 1.
Summary: The function correctly returns the square of the input, and cout prints it. Hence, the output of the program is 25, making A the correct answer.
When compiled and executed, what will the following C++ program display?
A. 0
B. T
C. T0
D. Test
Correct Answer: D
Explanation:
This question is about macros, conditional logic, and console output in C++. It specifically tests your knowledge of how macros are expanded by the preprocessor before compilation.
Macro Definition:
The macro defined as #define FUN(arg) if(arg) cout<<"Test"; replaces every use of FUN(condition) with if(condition) cout << "Test";.
Code Expansion:
In the main() function, the line FUN(i < 3); will be expanded by the preprocessor to:
This happens before the actual compilation.
Execution Flow:
The variable i is initialized to 1.
The condition i < 3 evaluates to true since 1 is indeed less than 3.
Therefore, the code inside the if statement (cout << "Test";) is executed.
This prints the string "Test" to the standard output.
No Additional Output:
There are no newline characters (\n) or extra text. So, the output will be exactly:
Option Analysis:
A (0) is incorrect—nothing in the code prints a zero.
B (T) implies partial output, which is not the case; "Test" is printed in full.
C (T0) is also invalid—there is no reason for 0 to be printed.
D (Test) is correct and matches the exact expected output.
Conclusion:
By using a macro with a conditional check, this program prints "Test" when i < 3 evaluates to true. That’s exactly what happens, so the correct answer is D.
A Six Sigma Black Belt is reviewing control charts for a process that has been operating consistently for several months. The latest X̄ chart shows that all data points are within control limits but display a consistent downward trend across 8 consecutive points.
What should the Black Belt conclude?
A. The process is stable and no action is required
B. The measurement system needs recalibration
C. A non-random pattern is present and should be investigated
D. Control limits should be adjusted to reflect the new trend
Correct Answer: C
This question assesses your understanding of statistical process control (SPC)—a core concept within the ASQ CSSBB Body of Knowledge, specifically Control Phase tools.
Let’s walk through what’s happening:
The scenario describes a process with an X̄ chart (mean control chart), used to monitor the central tendency of a process over time. All points lie within control limits, which might initially suggest the process is "in control." However, the key issue is the pattern of the data points: a consistent downward trend spanning 8 consecutive points.
In SPC, we not only monitor whether points are within control limits but also look for non-random patterns. According to Western Electric rules (also called Nelson rules), one such rule states that a run of 7 or more points trending consistently up or down is a signal of a special cause and not due to chance.
So, even if all points are technically within limits, a trend like this indicates a systematic shift in the process—possibly due to tool wear, drifting machine calibration, environmental conditions, or other assignable causes.
Now let’s consider each option:
A (Incorrect): The process appears stable but shows a non-random trend. So action is required.
B (Incorrect): There's no evidence here that the measurement system is faulty; the issue lies in the data trend.
C (Correct): A consistent trend across multiple points is a non-random signal, requiring investigation.
D (Incorrect): Control limits should not be adjusted arbitrarily to fit the data; we must first address special causes.
Therefore, the correct course of action is to investigate the trend, confirming that a non-random signal exists and that a special cause may be affecting the process.
Which of the following best describes the purpose of the SIPOC diagram in the Define phase of a Six Sigma project?
A. To identify the root cause of process defects
B. To map detailed process steps for cycle time reduction
C. To establish a high-level view of the process and its key elements
D. To quantify process capability metrics
Correct Answer: C
Explanation:
The SIPOC diagram (Suppliers, Inputs, Process, Outputs, Customers) is a high-level tool used during the Define phase of the DMAIC (Define, Measure, Analyze, Improve, Control) framework. Its primary purpose is to provide a structured overview of a process by identifying the key components that influence it.
SIPOC is particularly useful at the beginning of a project because it helps project teams and stakeholders align their understanding of the process scope. This is important in defining the problem statement, the project boundaries, and the primary goals. The diagram acts as a communication tool that ensures all team members and sponsors have a shared vision of what the process involves and how it interacts with internal or external customers.
Let’s look at why the other choices are incorrect:
A (Identify root cause) is typically addressed in the Analyze phase, not Define.
B (Detailed mapping) pertains more to tools like process flowcharts or value stream maps, which are used in later phases.
D (Quantify capability) refers to statistical tools such as Cp, Cpk, or Sigma level, used in the Measure phase.
In contrast, C accurately reflects the intent of SIPOC: to document who supplies inputs, what those inputs are, what the high-level steps of the process are, what outputs are produced, and who the customers are. This holistic view supports project charter development and scoping discussions.
In summary, the SIPOC diagram is a foundational tool that supports process understanding at the outset of a Six Sigma initiative. It’s not a detailed process analysis tool but a strategic overview mechanism. Hence, the correct answer is C.
In a Six Sigma project, which of the following best defines the role of a Black Belt during the Improve phase?
A. Establish process control plans
B. Facilitate team brainstorming to generate solution ideas
C. Validate measurement system accuracy
D. Perform stakeholder analysis
Correct Answer: B
Explanation:
The Improve phase of the DMAIC methodology focuses on developing, testing, and implementing solutions to address the root causes identified in the Analyze phase. At this stage, the Black Belt’s role becomes especially active in facilitating creative problem-solving and data-driven decision-making.
One of the most important responsibilities of the Black Belt in this phase is to lead brainstorming sessions, promote the use of techniques like design of experiments (DOE), FMEA, and cost-benefit analysis, and help the team generate and evaluate multiple potential solutions. The goal is not just to find a fix, but to ensure the chosen solution is optimal, effective, and sustainable.
Let’s review the other choices:
A (Establish control plans) is relevant to the Control phase, which ensures the improvements are maintained long-term.
C (Validate measurement system accuracy) falls under the Measure phase, where Gage R&R studies and system checks are conducted.
D (Stakeholder analysis) is part of project planning and occurs mainly in the Define phase to understand influence and involvement.
Black Belts use a variety of Lean and Six Sigma tools in the Improve phase, including 5 Whys, TRIZ, Kaizen, and Pugh matrices, to evaluate potential improvements. They also ensure that solution implementation is data-backed by testing hypotheses and measuring before-and-after performance.
Moreover, Black Belts are expected to motivate the team, manage change resistance, and coordinate with stakeholders to ensure that new processes are aligned with business objectives. This phase may involve pilot testing, risk assessment, and preparing for the Control phase handoff.
In conclusion, the primary role of a Six Sigma Black Belt during the Improve phase is to facilitate solution development through team collaboration and structured techniques. Therefore, the correct answer is B.
Site Search:
SPECIAL OFFER: GET 10% OFF
Pass your Exam with ExamCollection's PREMIUM files!
SPECIAL OFFER: GET 10% OFF
Use Discount Code:
MIN10OFF
A confirmation link was sent to your e-mail.
Please check your mailbox for a message from support@examcollection.com and follow the directions.
Download Free Demo of VCE Exam Simulator
Experience Avanset VCE Exam Simulator for yourself.
Simply submit your e-mail address below to get started with our interactive software demo of your free trial.