Mastering C++: A Comprehensive Quiz Based on 'Thinking in C++'

Disable ads (and more) with a membership for a one time $2.99 payment

Test your C++ skills with our quiz based on Bruce Eckel's 'Thinking in C++'. Dive into object-oriented programming, advanced topics, and fundamentals. Perfect for learners and experts alike. Assess your knowledge and become a C++ master!

Each practice test/flash card set has 50 randomly selected questions from a bank of over 500. You'll get a new set of questions each time!

Practice this question and more.


What is the behavior of the 'oneChar' function when called with a null pointer after being properly initialized?

  1. Resets 's' to point to the beginning of 'a'

  2. Continues returning the next character from 'a'

  3. Returns an error or an exception

  4. Starts returning characters from a default string

The correct answer is: Continues returning the next character from 'a'

When the 'oneChar' function is called with a null pointer, it will continue returning the next character from 'a'. This is because once the function has been properly initialized, it will continue to iterate through the characters of the string 'a' and return them one by one until it reaches the end of the string. This behavior will continue regardless of whether the function is called with a proper pointer or a null pointer. Option A is incorrect because there is no mention of 's' or 'a' in the context of the function. Option C is incorrect because there is no indication that the function will return an error or exception in this scenario. Option D is incorrect because there is no mention of a default string within the function or its context. Therefore, the correct answer is B.