NEC Prep

Programming Languages and Applications

NEC Computer Engineering · 1,949 practice MCQs

The 'Programming Languages and Applications' chapter is crucial for aspiring engineers preparing for the NEC licensing exam. It covers essential concepts in programming languages, including syntax, data types, and control structures.

Understanding these topics will not only enhance your coding skills but also ensure you can tackle multiple-choice questions effectively. To prepare, practice with our 1949 MCQs that reflect the actual exam content.

Sample questions with answers

  1. 1.Which type of implicit conversion is permitted by the compiler without exception?

    • A.class to int using operator int()
    • B.int to float
    • C.derived to non-related class
    • D.float to class instance

    Why: The conversion from int to float is permitted without exception because it is a safe conversion that does not result in data loss, as floating-point types can represent all integer values within their range.

  2. 2.What does ios::binary mode do?

    • A.Turns off newline conversion between '\n' and CRLF.
    • B.Makes files truncate when opened.
    • C.Moves the input pointer to the end.
    • D.Allows only formatted extraction.

    Why: The ios::binary mode prevents the automatic translation of newline characters, which means that the file will read and write data exactly as it is, without altering line endings.

  3. 3.What value does sizeof('A') give in C?

    • A.1
    • B.implementation-defined
    • C.4
    • D.2

    Why: The value of sizeof('A') is implementation-defined because the character literal 'A' can be represented in different ways depending on the system and compiler, leading to different sizes.

  4. 4.Which is FALSE about assignment operator?

    • A.Return type is usually reference to *this.
    • B.It must be global function.
    • C.It can be user-defined.
    • D.Default assignment is shallow copy.

    Why: The statement that the assignment operator must be a global function is false because the assignment operator can be defined as a member function of a class, allowing for object-specific behavior.

  5. 5.Which class serves as a base for ifstream and istringstream?

    • A.ios_base
    • B.ostream
    • C.iostream
    • D.istream

    Why: The istream class serves as the base class for both ifstream and istringstream, providing the fundamental input functionalities that these derived classes extend.

  6. 6.What is CORRECT about overriding in single inheritance?

    • A.The derived class can explicitly call the base version.
    • B.The base function must be declared as virtual.
    • C.The function signature should match exactly, except for return type (with covariance).
    • D.All of the above

    Why: All of the statements about overriding in single inheritance are correct; the derived class can call the base version, the base function must be virtual, and the function signatures must match except for the return type.

  7. 7.What statement will immediately stop a loop?

    • A.return
    • B.continue
    • C.break
    • D.goto

    Why: The break statement is used to immediately stop a loop, allowing the program to exit the loop and continue executing the code that follows it.

  8. 8.Which of the following loop behaviors is illegal?

    • A.Infinite for
    • B.while without braces
    • C.do-while without semicolon
    • D.for without increment

    Why: The do-while loop must end with a semicolon, and omitting it results in a syntax error, making it an illegal loop behavior.

  9. 9.What is true about whitespace in scanf’s format string?

    • A.Matches any amount of whitespace including newlines
    • B.Stops the scan immediately
    • C.Matches exactly one space
    • D.Ignored by scanf

    Why: In scanf's format string, whitespace matches any amount of whitespace, including spaces and newlines, allowing for flexible input parsing.

  10. 10.Which exception specification was completely removed in C++17?

    • A.noexcept
    • B.noexcept(false)
    • C.throw()
    • D.catch(...)

    Why: The exception specification 'throw()' was completely removed in C++17 because it was deemed unnecessary and not useful in modern C++ programming.

  11. 11.Which operator has the highest priority when accessing members of a structure?

    • A..
    • B.->
    • C.&
    • D.*

    Why: The -> operator has the highest priority when accessing members of a structure, allowing for direct access to the members of a structure through a pointer.

  12. 12.Which statement is valid concerning recursion?

    • A.At least one base case is logically required
    • B.Only global variables allowed
    • C.Function must be declared static
    • D.Inline keyword is necessary

    Why: At least one base case is logically required in recursion to prevent infinite loops and ensure that the recursive function can eventually terminate.

Practice all 1,949 Programming Languages and Applications questions

Adaptive mock tests, AI explanations on every question, and a personalized study plan.

Frequently asked questions

What type of implicit conversion is permitted by the compiler without exception?
The compiler allows 'promotion' of smaller data types to larger types without exception.
What does ios::binary mode do?
The ios::binary mode allows reading and writing of binary files, preventing any translation of newline characters.
What value does sizeof('A') give in C?
The value of sizeof('A') gives 1, as it measures the size of the character literal.
Which is FALSE about the assignment operator?
It is FALSE that the assignment operator can be overloaded for built-in types.
Which class serves as a base for ifstream and istringstream?
The class 'istream' serves as a base for both ifstream and istringstream.