Unit 1 - Practice Quiz

CSE202 50 Questions
0 Correct 0 Wrong 50 Left
0/50

1 Which header file is strictly required to use basic input/output operations like cin and cout in C++?

A. <iostream>
B. <conio.h>
C. <stdio.h>
D. <iomanip>

2 Which operator is used with the standard output stream (cout)?

A. >>
B. <<
C. ::
D. ->

3 In C++, what is the main focus of the Object-Oriented Programming paradigm compared to Procedural Programming?

A. Functions
B. Algorithms
C. Data
D. Hardware

4 Which approach is primarily followed in Object-Oriented Programming?

A. Top-down
B. Left-right
C. Linear
D. Bottom-up

5 What is the default access specifier for members of a Class in C++?

A. static
B. public
C. private
D. protected

6 What is the default access specifier for members of a Structure (struct) in C++?

A. internal
B. protected
C. private
D. public

7 Which of the following best describes a Class?

A. A blueprint for creating objects
B. A built-in data type
C. A variable referencing an address
D. A function library

8 What is the process of creating an object from a class called?

A. Instantiation
B. Inheritance
C. Polymorphism
D. Encapsulation

9 How does a Union differ from a Structure regarding memory allocation?

A. Unions allocate memory equal to the largest member
B. Unions do not allocate memory
C. Unions allocate memory equal to the sum of all members
D. Unions allocate memory for all members simultaneously

10 What is an Enumeration (enum) in C++?

A. A function that returns multiple values
B. A user-defined type consisting of named integral constants
C. A type of pointer
D. A class with only static members

11 Which operator is used to access a class member using an object instance?

A. :
B. ::
C. .
D. ->

12 Which operator is used to access a class member using a pointer to an object?

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

13 What is the keyword used to request the compiler to treat a function as an inline function?

A. static
B. const
C. inline
D. register

14 Which of the following is a disadvantage of inline functions?

A. Increases function call overhead
B. Increases binary executable size
C. Slower execution
D. Cannot access class members

15 If a member function is defined inside the class definition, it is treated as?

A. Virtual function
B. Friend function
C. Inline function
D. Static function

16 Where must a static data member be initialized?

A. Outside the class definition
B. Inside the class definition
C. Inside the main function
D. Inside the constructor

17 What is the default initial value of a static integer data member if not explicitly initialized?

A. Null
B. Garbage value
C. 1
D. 0

18 A static member function can access which of the following?

A. Only non-static members
B. Only private members
C. Both static and non-static members
D. Only static members

19 Which standard stream is meant for error messages?

A. clog
B. cout
C. cerr
D. cin

20 Which function is used to read a full line of text, including spaces, from cin?

A. getline()
B. read()
C. cin >>
D. scanf()

21 What rule applies to Default Arguments in a function declaration?

A. They must be assigned from right to left
B. They must be assigned from left to right
C. Only the first argument can be default
D. They can be assigned in any order

22 Which header file is required to use parameterized manipulators like setw()?

A. <iostream>
B. <fstream>
C. <iomanip>
D. <string>

23 What does the manipulator 'endl' do?

A. Inserts a null terminator
B. Inserts a new line only
C. Inserts a new line and flushes the buffer
D. Clears the screen

24 Function overloading allows multiple functions to have the same name if:

A. They have different access modifiers
B. They are in different files
C. They have different parameter lists (signatures)
D. They have different return types only

25 Which operator is known as the Scope Resolution Operator?

A. ::
B. :
C. ->
D. .

26 If a local variable has the same name as a global variable, how do you access the global variable?

A. extern variableName
B. ::variableName
C. global.variableName
D. this->variableName

27 What is a 'Friend Function'?

A. A function that inherits from the class
B. A function that is a member of the class
C. A non-member function that can access private and protected members of a class
D. A function accessible only to derived classes

28 Which statement about Friend Classes is true?

A. Friendship is mutual
B. Friendship is inherited
C. Friendship is public by default
D. Friendship is not mutual and not inherited

29 What is a Reference Variable?

A. A variable that holds a constant value
B. A pointer to a memory address
C. An alias or alternative name for an existing variable
D. A static variable

30 Which of the following syntax correctly declares a reference variable 'ref' for an integer 'a'?

A. int *ref = &a;
B. int &ref = a;
C. int ref = &a;
D. int ref = a;

31 In 'Call by Value', what happens to the actual arguments?

A. Their values are copied to formal parameters
B. Aliases are created
C. They are modified by the function
D. Their addresses are passed

32 In 'Call by Reference', how are arguments passed?

A. By passing an alias (reference) to the actual argument
B. By passing a pointer
C. By creating a copy
D. By passing the value

33 Which method of parameter passing requires the use of pointers in the function definition?

A. Call by value
B. Call by name
C. Call by address
D. Call by reference

34 What is the necessary condition for a recursive function to terminate?

A. A static variable
B. A loop
C. A global variable
D. A base case

35 Can a member function of a class be recursive?

A. Yes, member functions can call themselves
B. No, only global functions can be recursive
C. Only if it is a friend function
D. Only if it is a static member function

36 What is the scope of a variable declared inside a for loop initialization?

A. Function scope
B. File scope
C. Block scope (inside the loop only)
D. Global scope

37 Which symbol allows cascading of input/output operations?

A. << or >>
B. ;
C. ::
D. ,

38 What is the minimal size of an empty class in C++?

A. 1 byte
B. 2 bytes
C. 0 bytes
D. 4 bytes

39 Which feature of OOP allows hiding internal details and showing only functionality?

A. Inheritance
B. Polymorphism
C. Abstraction
D. Encapsulation

40 If a reference variable is declared, must it be initialized immediately?

A. Only if it is static
B. No
C. Only if it is const
D. Yes

41 Which of the following is NOT a characteristic of a static member function?

A. It does not have a 'this' pointer
B. It can be called without an object
C. It can access static members
D. It can access non-static members directly

42 What keyword allows a specific class to access private members of another class?

A. virtual
B. extern
C. friend
D. super

43 Which of the following creates a Manipulator that sets the field width to 10?

A. setw(10)
B. setprecision(10)
C. setfill(10)
D. width(10)

44 In function overloading, which of the following is NOT considered for differentiation?

A. Order of arguments
B. Return type
C. Number of arguments
D. Type of arguments

45 Which memory segment is used to store non-static local variables during recursion?

A. Heap
B. Code Segment
C. Stack
D. Data Segment

46 Can a 'friend' function be declared as 'const' or 'volatile'?

A. Only const
B. Yes
C. No
D. Only volatile

47 What happens if you define a function with default arguments but provide all arguments during the call?

A. Compiler Error
B. The default values are used regardless
C. The provided arguments override the defaults
D. Runtime Error

48 How is a Class different from an Object?

A. Class is a logical entity; Object is a physical entity
B. Object creates a Class
C. They are the same
D. Class is a variable; Object is a type

49 Which statement is true regarding the scope of class members defined as 'private'?

A. Accessible by derived classes
B. Accessible only within the class and by friends
C. Accessible by main() function
D. Accessible from anywhere

50 What is the correct way to define a member function outside the class?

A. ReturnType ClassName::FunctionName(Params) { ... }
B. friend ReturnType FunctionName(Params) { ... }
C. ClassName.FunctionName(Params) { ... }
D. ReturnType FunctionName(Params) { ... }