- What is the output of the following C code?
C
int x = 5;
printf(“%d %d %d”, x, x++, ++x);
A) 5 5 7
B) Undefined behavior ✅
C) 5 6 7
D) 7 6 5 - In C++, which keyword is used to prevent inheritance?
A) final ✅
B) static
C) const
D) sealed - What does sizeof(‘A’) return in C?
A) 1
B) 2
C) 4 ✅
D) Depends on compiler - Which feature is not part of OOP?
A) Encapsulation
B) Polymorphism
C) Compilation ✅
D) Inheritance - Which storage class has the longest lifetime?
A) auto
B) register
C) static
D) extern ✅ - What is the default access specifier in a class in C++?
A) public
B) private ✅
C) protected
D) friend - Which operator is used for pointer dereferencing?
A) &
B) * ✅
C) ->
D) . - What is the result of 10 % 3?
A) 1 ✅
B) 3
C) 0
D) 10 - Which function is used to allocate memory in C?
A) new
B) malloc() ✅
C) alloc()
D) create() - Which is not a valid C++ data type?
A) int
B) float
C) real ✅
D) char - What is function overloading?
A) Same function name with different parameters ✅
B) Same function name same parameters
C) Different functions same return type
D) Recursive functions - Which symbol is used for preprocessor directive?
A) $
B) # ✅
C) @
D) & - What is the size of pointer in 64-bit system?
A) 2 bytes
B) 4 bytes
C) 8 bytes ✅
D) 16 bytes - Which loop executes at least once?
A) for
B) while
C) do-while ✅
D) none - Which keyword is used to define constant in C?
A) final
B) const ✅
C) define
D) static - What is recursion?
A) Looping
B) Calling function within itself ✅
C) Memory allocation
D) Pointer usage - What is virtual function?
A) Static function
B) Inline function
C) Runtime polymorphism function ✅
D) Private function - Which operator is used to access structure member?
A) ->
B) . ✅
C) *
D) & - Which header file is required for printf()?
A) stdlib.h
B) conio.h
C) stdio.h ✅
D) math.h - Which keyword is used to dynamically allocate memory in C++?
A) malloc
B) new ✅
C) alloc
D) dynamic - What is inheritance?
A) Code reuse mechanism ✅
B) Function call
C) Looping
D) Compilation - Which is correct pointer declaration?
A) int p
B) int *p ✅
C) *int p
D) int &p - Which concept binds data and functions together?
A) Inheritance
B) Polymorphism
C) Encapsulation ✅
D) Abstraction - What is operator overloading?
A) Redefining operators ✅
B) Looping operators
C) Pointer usage
D) Compilation - Which function frees allocated memory?
A) free() ✅
B) delete
C) remove()
D) release() - What is namespace in C++?
A) Variable
B) Class
C) Scope resolution tool ✅
D) Function - Which keyword is used to inherit class?
A) inherits
B) extends
C) : ✅
D) super - What is the output of sizeof(int) in most systems?
A) 2
B) 4 ✅
C) 8
D) 16 - Which is not a loop structure?
A) for
B) while
C) repeat-until ✅
D) do-while - Which operator is used for address-of variable?
A) *
B) & ✅
C) ->
D) . - What is polymorphism?
A) Many forms of function ✅
B) Single function
C) Looping
D) Pointer - Which function is entry point in C program?
A) start()
B) main() ✅
C) init()
D) run() - Which keyword is used to define class?
A) struct
B) class ✅
C) object
D) define - Which is used to handle exception?
A) catch
B) throw
C) try
D) All of these ✅ - What is abstraction?
A) Hiding implementation details ✅
B) Loop
C) Memory
D) Pointer - Which operator is used for member access via pointer?
A) .
B) -> ✅
C) *
D) & - Which data type stores single character?
A) int
B) char ✅
C) float
D) double - Which keyword is used for inline function?
A) inline ✅
B) static
C) virtual
D) extern - What is dangling pointer?
A) Valid pointer
B) Null pointer
C) Pointer to freed memory ✅
D) Pointer to array - Which concept supports code reusability?
A) Inheritance ✅
B) Loop
C) Pointer
D) Function - What is default return type of main()?
A) void
B) int ✅
C) char
D) float - Which operator has highest precedence?
A) *
B) +
C) () ✅
D) = - What is function prototype?
A) Function body
B) Declaration of function ✅
C) Loop
D) Pointer - Which storage class restricts scope to file?
A) static ✅
B) extern
C) auto
D) register - Which is not a valid keyword in C++?
A) virtual
B) friend
C) export
D) include ✅ - What is friend function?
A) Member function
B) External function with access to private data ✅
C) Inline function
D) Virtual function - Which concept allows same function name different behavior?
A) Overloading ✅
B) Encapsulation
C) Loop
D) Pointer - Which keyword is used to exit loop?
A) continue
B) break ✅
C) stop
D) exit - Which operator is used for scope resolution?
A) :
B) :: ✅
C) .
D) -> - Which concept allows hiding data?
A) Encapsulation ✅
B) Polymorphism
C) Inheritance
D) Loop
Pages: 1 2