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. <stdio.h>
B. <conio.h>
C. <iostream>
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. Data
B. Algorithms
C. Functions
D. Hardware

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

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

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

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

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

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

7 Which of the following best describes a Class?

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

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

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

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 user-defined type consisting of named integral constants
B. A function that returns multiple values
C. A class with only static members
D. A type of pointer

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. register
C. inline
D. const

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

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

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

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

16 Where must a static data member be initialized?

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

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

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

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

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

19 Which standard stream is meant for error messages?

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

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

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

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

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

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

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

23 What does the manipulator 'endl' do?

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

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

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

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. ::variableName
B. this->variableName
C. global.variableName
D. extern variableName

27 What is a 'Friend Function'?

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

28 Which statement about Friend Classes is true?

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

29 What is a Reference Variable?

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

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. Their addresses are passed
C. Aliases are created
D. They are modified by the function

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

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

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

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

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

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

35 Can a member function of a class be recursive?

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

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

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

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. 2 bytes
B. 1 byte
C. 4 bytes
D. 0 bytes

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

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

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

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

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 access non-static members directly
C. It can be called without an object
D. It can access static members

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

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

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

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

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

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

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

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

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

A. Yes
B. Only const
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 provided arguments override the defaults
C. Runtime Error
D. The default values are used regardless

48 How is a Class different from an Object?

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

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

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

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

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