C++ Programming Trivia Questions Test: Can You Pass This Quiz?

Approved & Edited by ProProfs Editorial Team
The editorial team at ProProfs Quizzes consists of a select group of subject experts, trivia writers, and quiz masters who have authored over 10,000 quizzes taken by more than 100 million users. This team includes our in-house seasoned quiz moderators and subject matter experts. Our editorial experts, spread across the world, are rigorously trained using our comprehensive guidelines to ensure that you receive the highest quality quizzes.
Learn about Our Editorial Process
| By Srikanth_kanthet
S
Srikanth_kanthet
Community Contributor
Quizzes Created: 5 | Total Attempts: 867
Questions: 20 | Attempts: 149

SettingsSettingsSettings
C++ Programming Trivia Questions Test: Can You Pass This Quiz? - Quiz

Are you looking for a C++ Programming Trivia Questions Test? The quiz below is perfect for seeing just how much you know about this language and if it is enough to earn you a good score in the certification exam. Can You Pass This Quiz? How about you give it a shot and see how well you will do!


Questions and Answers
  • 1. 

    Can we have overloaded virtual functions?

    • A.

      True

    • B.

      False

    Correct Answer
    A. True
    Explanation
    Yes, we can have overloaded virtual functions. In object-oriented programming, a virtual function is a function that is declared in a base class and can be overridden by a derived class. Overloading a function means having multiple functions with the same name but different parameters. Therefore, it is possible to have multiple virtual functions with the same name but different parameters, resulting in overloaded virtual functions.

    Rate this question:

  • 2. 

    Is “this” is a reference variable?

    • A.

      True

    • B.

      False

    Correct Answer
    B. False
    Explanation
    The statement "this" is not a reference variable. "this" is a keyword in Java that refers to the current object. It is used to differentiate between instance variables and parameters with the same name. It does not hold any value or reference to an object, so it cannot be considered a reference variable.

    Rate this question:

  • 3. 

    Which is the highest precedence operator? 

    Correct Answer
    ()
    Explanation
    The parentheses operator () has the highest precedence in mathematical expressions. This means that any expression inside the parentheses is evaluated first before any other operation is performed. It is used to control the order of operations and can be used to override the default precedence rules.

    Rate this question:

  • 4. 

    Oracle engine automatically locks table data while executing SQL statements

    • A.

      True

    • B.

      False

    Correct Answer
    A. True
    Explanation
    The given answer is true because Oracle engine automatically locks table data while executing SQL statements. This means that when a SQL statement is being executed, Oracle will lock the relevant table data to ensure data integrity and prevent concurrent access issues. This locking mechanism helps in maintaining the consistency and accuracy of the data being accessed or modified by multiple users or processes simultaneously.

    Rate this question:

  • 5. 

    Is the below syntax is correct?      Exception           when OTHERS THEN              DBMS_OUTPUT.PUT_LINE("ERROR");            WHEN TOO-MANY-ROWS-FOUND THEN              DBMS_OUTPUT.PUT_LINE("MORE ROWS FOUND");

    • A.

      True

    • B.

      False

    Correct Answer
    B. False
    Explanation
    The given syntax is not correct. The keyword "Exception" should be replaced with "EXCEPTION" in PL/SQL. Additionally, the exception name "TOO-MANY-ROWS-FOUND" should be enclosed in double quotation marks. Therefore, the correct syntax would be:
    EXCEPTION
             WHEN OTHERS THEN
                 DBMS_OUTPUT.PUT_LINE("ERROR");
             WHEN 'TOO-MANY-ROWS-FOUND' THEN
                 DBMS_OUTPUT.PUT_LINE("MORE ROWS FOUND");
    Therefore, the answer is False.

    Rate this question:

  • 6. 

    Can we define a class inside another class? 

    • A.

      True

    • B.

      False

    Correct Answer
    A. True
    Explanation
    Yes, we can define a class inside another class. This is known as a nested class or inner class. The nested class is a way to logically group classes that are only used in one place and helps in better organization of code. The nested class has access to the members of the outer class, including private members, and can be instantiated within the outer class or outside of it.

    Rate this question:

  • 7. 

    Static member variables of a class can be initialized by using Constructor?

    • A.

      True

    • B.

      False

    Correct Answer
    B. False
    Explanation
    Static member variables of a class cannot be initialized using a constructor. Constructor is used to initialize instance variables, which are specific to each object of the class. Static member variables, on the other hand, are shared among all objects of the class and are initialized separately using static initialization blocks or by directly assigning a value to them. Therefore, the statement is false.

    Rate this question:

  • 8. 

    Which is the lowest precedence operator? 

    Correct Answer
    ,(comma)
    Explanation
    The lowest precedence operator is the comma (,). This operator is used to separate expressions or values in a list. It has the lowest precedence because it evaluates each expression from left to right, without any specific order of operations.

    Rate this question:

  • 9. 

    There is a limit to the number of cursors that can be opened in a session.

    • A.

      True

    • B.

      False

    Correct Answer
    A. True
    Explanation
    The statement is true because in most database systems, there is a limit to the number of cursors that can be opened in a session. Cursors are used to retrieve and manipulate data from a result set, and opening too many cursors can consume significant system resources. Therefore, to prevent resource exhaustion and optimize performance, a limit is imposed on the number of cursors that can be opened in a session.

    Rate this question:

  • 10. 

    Can we use a commit statement within a database trigger?

    • A.

      True

    • B.

      False

    Correct Answer
    B. False
    Explanation
    A commit statement is used to permanently save changes made in a transaction. However, using a commit statement within a database trigger is not allowed because triggers are automatically executed as part of a transaction. If a commit statement is used within a trigger, it would cause the trigger to be fired again, resulting in an infinite loop. Therefore, it is not possible to use a commit statement within a database trigger.

    Rate this question:

  • 11. 

    Can constructor throw an exception?

    • A.

      True

    • B.

      False

    Correct Answer
    A. True
    Explanation
    Yes, a constructor can throw an exception. When a constructor encounters an error or a condition that prevents it from properly initializing an object, it can throw an exception to indicate the failure. This allows the caller of the constructor to handle the exception and take appropriate action. Exceptions thrown in a constructor can be caught using try-catch blocks, allowing for error handling and graceful recovery. Therefore, the statement "True" is correct.

    Rate this question:

  • 12. 

    Can we have duplicate cases in the switch?

    • A.

      True

    • B.

      False

    Correct Answer
    B. False
    Explanation
    In a switch statement, each case must be unique. If there are duplicate cases, it will result in a compilation error. Each case is used to match a specific value, and if there are duplicates, it would create ambiguity in the code and make it unclear which case should be executed. Therefore, duplicate cases are not allowed in a switch statement.

    Rate this question:

  • 13. 

    Can we have virtual constructors?

    • A.

      True

    • B.

      False

    Correct Answer
    B. False
    Explanation
    Virtual constructors are not possible in most programming languages. Constructors are special member functions that are used to initialize objects of a class. They are called automatically when an object is created. However, virtual functions are used for dynamic polymorphism, allowing derived classes to override the behavior of base class functions. Constructors cannot be virtual because they are called during object creation, before the object's type is determined. Therefore, the answer is false.

    Rate this question:

  • 14. 

    Can we write trigger on views?

    • A.

      True

    • B.

      False

    Correct Answer
    A. True
    Explanation
    Yes, we can write triggers on views. A trigger is a special type of stored procedure that automatically executes when an event (such as an insert, update, or delete) occurs on a table or view. Triggers can be used to enforce business rules, perform data validation, or update other tables/views based on the changes made to the underlying data. Therefore, it is possible to create triggers on views to perform specific actions whenever data in the view is modified.

    Rate this question:

  • 15. 

    IN is faster than EXISTS.

    • A.

      True

    • B.

      False

    Correct Answer
    B. False
    Explanation
    The statement "IN is faster than EXISTS" is false. In SQL, the EXISTS keyword is generally faster than using the IN operator. The EXISTS keyword checks for the existence of a subquery result, while the IN operator compares a value with a set of values. The EXISTS keyword stops evaluating as soon as it finds a match, while the IN operator evaluates all the values in the set. Therefore, when dealing with large datasets, using EXISTS can result in better performance compared to using IN.

    Rate this question:

  • 16. 

    42 is the ASCII value of '\0' 

    • A.

      True

    • B.

      False

    Correct Answer
    B. False
    Explanation
    The ASCII value of '\0' is actually 0, not 42. Therefore, the statement that 42 is the ASCII value of '\0' is false.

    Rate this question:

  • 17. 

    Can we call the destructor explicitly?

    • A.

      True

    • B.

      False

    Correct Answer
    A. True
    Explanation
    Yes, we can call the destructor explicitly in C++. This can be done by using the delete keyword followed by the object's name. However, it is generally not recommended to call the destructor explicitly unless there is a specific need, as the destructor is automatically called when an object goes out of scope or is deleted. Calling the destructor explicitly can lead to undefined behavior if the object is accessed after its destruction.

    Rate this question:

  • 18. 

    Can we overload '->' operator?

    • A.

      True

    • B.

      False

    Correct Answer
    B. False
    Explanation
    The '-' operator in C++ cannot be overloaded. It is a built-in operator and its behavior cannot be changed. Overloading operators is only possible for certain operators such as arithmetic, comparison, and assignment operators.

    Rate this question:

  • 19. 

    The name of the table can be changed using the ALTER TABLE clause.

    • A.

      True

    • B.

      False

    Correct Answer
    B. False
    Explanation
    The name of the table cannot be changed using the ALTER TABLE clause.

    Rate this question:

  • 20. 

    Check constraint consists of subqueries and sequences.

    • A.

      True

    • B.

      False

    Correct Answer
    B. False
    Explanation
    The given statement is incorrect. Check constraints do not consist of subqueries and sequences. Check constraints are used to enforce specific conditions on the values entered into a column. They can be used to ensure that only certain values are allowed in a column or to restrict the range of values that can be entered. Subqueries and sequences are not directly related to check constraints.

    Rate this question:

Quiz Review Timeline +

Our quizzes are rigorously reviewed, monitored and continuously updated by our expert board to maintain accuracy, relevance, and timeliness.

  • Current Version
  • Mar 18, 2023
    Quiz Edited by
    ProProfs Editorial Team
  • Sep 12, 2012
    Quiz Created by
    Srikanth_kanthet
Back to Top Back to top
Advertisement
×

Wait!
Here's an interesting quiz for you.

We have other quizzes matching your interest.