0% found this document useful (0 votes)
51 views33 pages

Unit 2

The document contains questions and answers about various programming concepts in C and C++ including variables, keywords, typecasting, iteration, and enumeration. It tests knowledge of data types, variable scope, operators, control structures, and other fundamental programming topics. The questions cover the purpose and usage of variables, constants, keywords like const and static, type conversion methods like casting, loop types like for and while, and enumerated types for defining sets of named integer values.

Uploaded by

GOPI NADH P
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
51 views33 pages

Unit 2

The document contains questions and answers about various programming concepts in C and C++ including variables, keywords, typecasting, iteration, and enumeration. It tests knowledge of data types, variable scope, operators, control structures, and other fundamental programming topics. The questions cover the purpose and usage of variables, constants, keywords like const and static, type conversion methods like casting, loop types like for and while, and enumerated types for defining sets of named integer values.

Uploaded by

GOPI NADH P
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 33

UNIT 2

CONCEPT OF PROGRAMMING USING C AND C++,OPERATING


SYSTEM,DATA STRUCTURES

VARIABLES

1. What is the purpose of a variable in programming?


- A) To store and represent data
- B) To perform mathematical operations
- C) To control program flow
- D) To create loops

Answer: A

2. Which data type is used to store whole numbers in C++?


- A) float
- B) double
- C) int
- D) char

Answer: C

3. In C, what is the keyword used for declaring a constant?


- A) var
- B) final
- C) const
- D) constant

Answer: C

4. What is the scope of a local variable in C++?


- A) Global
- B) File
- C) Local
- D) Both A and C

Answer: C

5. Which of the following is a valid variable name in C?


- A) 123variable
- B) _variable
- C) variable-name
- D) All of the above

Answer: B

6. Which of the following operators is used to find the size of a data type in C++?
- A) size of
- B) size
- C) lengthof
- D) length

Answer: A

7. What is the default value of an uninitialized variable in C?


- A) 0
- B) 1
- C) Random
- D) Null

Answer: C

8. In C++, what is the difference between '++i' and 'i++'?


- A) No difference
- B) '++i' increments before the value is used
- C) 'i++' increments after the value is used
- D) '++i' is used for floating-point variables, and 'i++' for integers

Answer: B

9. Which data type is used to store characters in C?


- A) char
- B) string
- C) character
- D) byte

Answer: A

10. What is the purpose of the 'volatile' keyword in C++?


- A) To declare a variable as unchangeable
- B) To indicate that the variable may be changed at any time by external forces
- C) To speed up variable access
- D) To declare a constant variable

Answer: B

KEYWORDS

1. Which C++ keyword is used for dynamic memory allocation?


- A) new
- B) malloc
- C) allocate
- D) dynamic

Answer: A

2. In C, what keyword is used to exit a loop prematurely?


- A) break
- B) exit
- C) terminate
- D) end

Answer: A

3. What is the purpose of the 'const' keyword in C++?


- A) To declare a constant
- B) To define a function
- C) To indicate a comment
- D) To represent a conditional statement

Answer: A

4. Which keyword is used to define a macro in C?


- A) define
- B) macro
- C) def
- D) const

Answer: A

5. What is the role of the 'auto' keyword in C++?


- A) To automatically allocate memory
- B) To automatically determine the data type of a variable
- C) To automate file input/output
- D) To define automatic functions

Answer: B

6. Which keyword is used in C++ to implement exception handling?


- A) throw
- B) catch
- C) exception
- D) try

Answer: D

7. What does the 'static' keyword do in C?


- A) Allocates memory dynamically
- B) Declares a constant
- C) Specifies internal linkage for a variable
- D) Defines a global variable

Answer: C

8. In C++, what is the purpose of the 'virtual' keyword in function declaration?


- A) To specify a pure virtual function
- B) To indicate a constant function
- C) To enable function overloading
- D) To enable function overriding

Answer: D

9. Which keyword is used to define an alias for a data type in C?


- A) typedef
- B) alias
- C) define
- D) type

Answer: A

10. What is the function of the 'register' keyword in C?


- A) To declare a variable as a register variable
- B) To register a function in the operating system
- C) To enable debugging
- D) To register a variable in the memory management system

Answer: A

TYPECASTING

1. What is typecasting in programming?


- A) Casting spells on variables
- B) Converting one data type to another
- C) Assigning a type to a variable
- D) Creating new data types

Answer: B

2. Which type of typecasting is known as implicit typecasting?


- A) static_cast
- B) dynamic_cast
- C) explicit_cast
- D) automatic_cast

Answer: D

3. In C++, what is the purpose of the 'typeid' operator in typecasting?


- A) To check the type of a variable
- B) To cast a variable to a specific type
- C) To define a new data type
- D) To get the size of a variable

Answer: A

4. What is the role of the 'reinterpret_cast' operator in C++ typecasting?


- A) Converts one pointer type to another
- B) Converts integers to floating-point numbers
- C) Converts characters to integers
- D) Converts one string type to another

Answer: A

5. Which type of typecasting must be explicitly done by the programmer?


- A) Implicit typecasting
- B) Explicit typecasting
- C) Automatic typecasting
- D) Dynamic typecasting

Answer: B

6. What is the result of typecasting a floating-point number to an integer in C?


- A) Truncates the decimal part
- B) Rounds to the nearest integer
- C) Converts to the absolute value
- D) Generates a compilation error

Answer: A

7. Which C++ operator is used for

explicit type conversion?


- A) cast
- B) typecast
- C) convert
- D) explicit

Answer: A

8. What is the purpose of the 'dynamic_cast' operator in C++?


- A) To perform dynamic type conversion
- B) To convert between different pointer types
- C) To dynamically allocate memory
- D) To cast dynamically allocated variables

Answer: B

9. Which keyword is used for typecasting in C?


- A) cast
- B) convert
- C) typecast
- D) None of the above

Answer: D

10. What happens if you try to typecast a pointer to a non-related data type using 'static_cast'?
- A) It is allowed
- B) Generates a compilation error
- C) Results in a runtime error
- D) Automatically adjusts the pointer size

Answer: B

ITERATION

1. Which of the following is not a loop structure in C++?


- A) for
- B) repeat
- C) while
- D) do-while

Answer: B

2. In C, what does the 'break' statement do in a loop?


- A) Skips the next iteration
- B) Terminates the loop prematurely
- C) Continues to the next iteration
- D) Repeats the loop

Answer: B

3. Which loop in C++ is guaranteed to execute at least once?


- A) for
- B) while
- C) do-while
- D) repeat-until

Answer: C

4. What is the purpose of the 'continue' statement in a loop?


- A) Terminates the loop
- B) Skips the rest of the loop and moves to the next iteration
- C) Jumps to a specific label
- D) Repeats the loop

Answer: B

5. In C++, what is the role of the 'range-based for loop'?


- A) Executes a loop for a specified range of values
- B) Performs operations on a range of data types
- C) Iterates over the elements of a container or array
- D) Breaks the loop when a condition is met

Answer: C

6. What does the 'do-while' loop guarantee in C?


- A) It guarantees at least one iteration
- B) It guarantees a specific number of iterations
- C) It guarantees a conditional iteration
- D) It guarantees an infinite loop

Answer: A

7. Which loop structure is suitable when the number of iterations is known beforehand in C?
- A) while
- B) do-while
- C) for
- D) switch

Answer: C

8. What is the purpose of the 'goto' statement in C++?


- A) Jumps to a specific label in the code
- B) Exits the loop prematurely
- C) Repeats the loop
- D) Skips the next iteration

Answer: A

9. How is an infinite loop created in C?


- A) Using 'for' loop with a true condition
- B) Using 'while' loop with a false condition
- C) Using 'do-while' loop with a break statement
- D) Using 'for' loop with a counter

Answer: A

10. What is the primary difference between 'while' and 'do-while' loops in C++?
- A) Syntax
- B) Performance
- C) The condition is checked before or after the loop body
- D) They are identical

Answer: C

ENUMERATION

1. What is an enumeration in C++?


- A) A loop structure
- B) A data type consisting of named integer constants
- C) A type of typecasting
- D) A keyword to define constants

Answer: B

2. Which keyword is used to define an enumeration in C++?


- A) enum
- B) enum_type
- C) enumeration
- D) define_enum

Answer: A

3. What is the default starting value of the first element in an enumeration in C++?
- A) 0
- B) 1
- C) 10
- D) -1

Answer: A

4. How can you explicitly set values for elements in a C++ enumeration?
- A) Using the 'set' keyword
- B) Using the 'values' keyword
- C) Assigning values within curly braces
- D) Enumerations cannot have explicit values

Answer: C

5. What is the purpose of enumerations in C++?


- A) To create loops
- B) To represent a set of named integer constants
- C) To define constants
- D) To allocate memory dynamically

Answer: B

6. Which of the following is a valid way to access an enumeration element in C++?


- A) EnumName.element
- B) EnumName::element
- C) EnumName->element
- D) EnumName[element]

Answer: B

7. In C++, can you assign a value to an enumeration element that is not explicitly defined?
- A) Yes, it is allowed
- B) No, it results in a compilation error
- C) Only if the element is at the end of the enumeration
- D) Only if the element is the first in the enumeration

Answer: A

8. What is the primary advantage of using enumerations in C++?


- A) They save memory
- B) They provide a way to represent named integer constants
- C) They improve program speed
- D) They allow dynamic allocation of memory
Answer: B

9. Can you perform arithmetic operations with enumeration elements in C++?


- A) Yes, using standard arithmetic operators
- B) No, it is not allowed
- C) Only if the enumeration is explicitly declared as 'arithmetic'
- D) Only if the enumeration has consecutive integer values

Answer: A

10. What is the purpose of the 'sizeof' operator when used with an enumeration in C++?
- A) To find the size of the enumeration
- B) To find the size of an element in the enumeration
- C) To find the number of elements in the enumeration
- D) To find the total size of the enumeration and its elements

Answer: A

C PREPROCESSORS

1. What is the purpose of the `#define` directive in C?


- A. Declare a variable
- B. Define a function
- C. Create a macro
- D. Include a header file
- Answer: C. Create a macro

2. Which directive is used to include the contents of a file in C?


- A. #define
- B. #include
- C. #ifdef
- D. #pragma
- Answer: B. #include

3. What does the `#ifndef` directive stand for?


- A. Not Found
- B. No Function
- C. Not Hash Define
- D. Not If Defined
- Answer: D. Not If Defined

4. In C preprocessor, what is the purpose of the `#undef` directive?


- A. Undefine a macro
- B. Define a macro
- C. Include a file
- D. Declare a variable
- Answer: A. Undefine a macro

5. Which operator is used for string concatenation in C preprocessor macros?


- A. &
- B. *
- C. #
- D. %
- Answer: C. #

6. What is the purpose of the `#pragma` directive in C?


- A. Declare variables
- B. Include header files
- C. Provide compiler-specific instructions
- D. Define functions
- Answer: C. Provide compiler-specific instructions

7. Which directive is used for conditional compilation in C?


- A. #ifdef
- B. #define
- C. #if
- D. #else
- Answer: C. #if

8. What does the `##` operator do in C preprocessor macros?


- A. Concatenates two strings
- B. Multiplies two numbers
- C. Defines a macro
- D. Undefines a macro
- Answer: A. Concatenates two strings

9. What is the purpose of the `#error` directive in C preprocessor?


- A. Print an error message
- B. Define a macro
- C. Include a file
- D. Undefine a macro
- Answer: A. Print an error message

10. Which directive is used to check if a macro is defined in C?


- A. #ifdef
- B. #ifndef
- C. #if
- D. #define
- Answer: A. #ifdef

CONSTRUCTOR AND DESTRUCTOR

1. Which of the following is called automatically when an object is created in C++?


- A. Constructor
- B. Destructor
- C. Main function
- D. Operator overloading
- Answer: A. Constructor

2. What is the purpose of a destructor in C++?


- A. Initialize object members
- B. Allocate memory
- C. Deallocate resources and perform cleanup
- D. Define object behavior
- Answer: C. Deallocate resources and perform cleanup

3. How is a constructor different from a regular member function in C++?


- A. Constructors are private, and member functions are public
- B. Constructors have no return type, and member functions do
- C. Member functions are called automatically, and constructors are not
- D. Constructors can't be overloaded, but member functions can
- Answer: B. Constructors have no return type, and member functions do

4. Which keyword is used to declare a destructor in C++?


- A. ~destructor()
- B. destroy()
- C. Destruct
- D. ~ClassName()
- Answer: D. ~ClassName()

5. When is the destructor called in C++?


- A. Before the object is created
- B. After the object is created
- C. Before the object goes out of scope or is explicitly deleted
- D. After the main function completes execution
- Answer: C. Before the object goes out of scope or is explicitly deleted

6. Can a class have multiple constructors in C++?


- A. Yes, but only one constructor
- B. No, only one constructor is allowed
- C. Yes, multiple constructors with different parameters
- D. No, constructors are not allowed in classes
- Answer: C. Yes, multiple constructors with different parameters

7. What happens if you don't provide a constructor for a class in C++?


- A. The compiler generates a default constructor
- B. The class cannot be instantiated
- C. The program won't compile
- D. The constructor is automatically inherited from the base class
- Answer: A. The compiler generates a default constructor

8. Which of the following statements is true about copy constructors in C++?


- A. They are used to create a new object
- B. They take an object of the same class as a parameter
- C. They are automatically generated by the compiler
- D. Both B and C
- Answer: D. Both B and C

9. What is the purpose of the default constructor in C++?


- A. Initialize object members to default values
- B. Copy an existing object
- C. Deallocate resources
- D. Create a new object
- Answer: A. Initialize object members to default values

10. In C++, can a destructor be overloaded?


- A. Yes
- B. No
- C. Only in derived classes
- D. Only in virtual classes
- Answer: B. No

POINTERS

1. What is a pointer in C++?


- A. A variable that stores a memory address
- B. A function that returns an address
- C. A special type of variable
- D. A variable that stores an integer
- Answer: A. A variable that stores a memory address

2. How is the dereference operator (*) used with pointers?


- A. To declare a pointer variable
- B. To access the value pointed by a pointer
- C. To get the memory address of a variable
- D. To perform arithmetic operations
- Answer: B. To access the value pointed by a pointer

3. What is the result of incrementing a

pointer by 1 in C++?
- A. The address increases by 1 byte
- B. The address increases by the size of the data type
- C. The address decreases by 1 byte
- D. The address remains the same
- Answer: B. The address increases by the size of the data type

4. What is a null pointer in C++?


- A. A pointer that points to address 0
- B. A pointer with a value of -1
- C. A pointer with a value of 1
- D. A pointer with an undefined value
- Answer: A. A pointer that points to address 0

5. What is the purpose of the `new` operator in C++?


- A. Allocate memory for a variable on the heap
- B. Create a new variable
- C. Declare a pointer variable
- D. Initialize a pointer
- Answer: A. Allocate memory for a variable on the heap
6. How do you free the memory allocated by the `new` operator in C++?
- A. Using the `delete` operator
- B. Using the `free` function
- C. Automatically done by the system
- D. Memory is automatically released when the program ends
- Answer: A. Using the `delete` operator

7. What is the purpose of the `const` keyword when used with pointers in C++?
- A. It makes the pointer constant
- B. It makes the pointed value constant
- C. It makes both the pointer and pointed value constant
- D. It has no effect on pointers
- Answer: C. It makes both the pointer and pointed value constant

8. What is the difference between an array and a pointer in C++?


- A. Arrays cannot be passed to functions
- B. Pointers cannot be used for string manipulation
- C. Arrays have a fixed size, while pointers can point to different locations
- D. Pointers cannot be used as function arguments
- Answer: C. Arrays have a fixed size, while pointers can point to different locations

9. What is the purpose of the arrow operator (->) in C++?


- A. Access the value pointed by a pointer
- B. Access the address of a variable
- C. Access a member of a structure or class through a pointer
- D. Perform arithmetic operations on pointers
- Answer: C. Access a member of a structure or class through a pointer

10. What is the significance of the `void` pointer in C++?


- A. It points to null
- B. It can point to any data type
- C. It is used for arithmetic operations only
- D. It is used exclusively with arrays
- Answer: B. It can point to any data type

INHERITANCE

1. What is inheritance in C++?


- A. Copying code from one class to another
- B. Creating new classes based on existing classes
- C. Implementing interfaces
- D. Declaring multiple classes in one file
- Answer: B. Creating new classes based on existing classes

2. Which keyword is used to implement inheritance in C++?


- A. using
- B. inherit
- C. extends
- D. class
- Answer: D. class

3. What is the access specifier used to indicate that a member of a base class is accessible in
the derived class, but not from outside?
- A. public
- B. private
- C. protected
- D. internal
- Answer: C. protected

4. In C++, can a derived class inherit from multiple base classes?


- A. Yes, always
- B. No, never
- C. Yes, but with restrictions
- D. Only if the base classes have the same name
- Answer: C. Yes, but with restrictions

5. What is the term used to describe the ability of a class to provide methods that have the
same name but different implementations?
- A. Polymorphism
- B. Overloading
- C. Inheritance
- D. Encapsulation
- Answer: B. Overloading

6. What is the purpose of the virtual keyword in C++ in the context of inheritance?
- A. Declares a member variable
- B. Declares a pure virtual function
- C. Specifies that a function can be overridden
- D. Indicates a static member function
- Answer: C. Specifies that a function can be overridden

7. What is the primary advantage of using inheritance in programming?


- A. Code reuse and extensibility
- B. Improved performance
- C. Simplicity of syntax
- D. Enhanced security
- Answer: A. Code reuse and extensibility

8. Which type of inheritance allows a class to inherit from multiple classes but with no
common base class?
- A. Hierarchical inheritance
- B. Multiple inheritance
- C. Single inheritance
- D. Hybrid inheritance
- Answer: B. Multiple inheritance

9. What is the term used to describe a class that cannot be instantiated and is meant only for
deriving other classes?
- A. Abstract class
- B. Concrete class
- C. Final class
- D. Base class
- Answer: A. Abstract class

10. In C++, can a derived class access private members of its base class?
- A. Yes, always
- B. No, never
- C. Yes, if the base class is abstract
- D. Yes, if friend functions are used
- Answer: B. No, never

POLYMORPHISM

1. What does the term "polymorphism" mean in the context of programming?


- A. Many forms
- B. Many variables
- C. Many classes
- D. Many functions
- Answer: A. Many forms

2. Which type of polymorphism is achieved through function overloading and operator


overloading?
- A. Compile-time polymorphism
- B. Run-time polymorphism
- C. Static polymorphism
- D. Dynamic polymorphism
- Answer: A. Compile-time polymorphism

3. What is the purpose of the virtual keyword when used with functions in C++?
- A. Declares a static function
- B. Declares a pure virtual function
- C. Indicates that a function can be overridden
- D. Specifies a friend function
- Answer: C. Indicates that a function can be overridden

4. What is runtime polymorphism in C++ often achieved through?


- A. Function overloading
- B. Operator overloading
- C. Inheritance and virtual functions
- D. Templates
- Answer: C. Inheritance and virtual functions

5. What is the term for having multiple methods in a base class with the same name but
different implementations in derived classes?
- A. Function overloading
- B. Function overriding
- C. Function hiding
- D. Function masking
- Answer: B. Function overriding
6. Which keyword is used to declare a pure virtual function in C++?
- A. abstract
- B. virtual
- C. pure
- D. none of the above
- Answer: C. pure

7. In C++, can a pure virtual function have a definition in the abstract base class?
- A. Yes, always
- B. No, never
- C. Yes, but only if it has a body
- D. Yes, if it is private
- Answer: B. No, never

8. What is the term for the ability of a function to operate on different types or numbers of
arguments?
- A. Function overloading
- B. Function overriding
- C. Operator overloading
- D. Template function
- Answer: D. Template function

9. In C++, what is the purpose of the typeid operator?


- A. To determine the type of an object at runtime
- B. To declare a type
- C. To define a type
- D. To identify a type in the preprocessor
- Answer: A. To determine the type of an object at runtime

10. What is the concept of function overloading in C++?


- A. Multiple functions with the same name but different return types
- B. Multiple functions with the same name and parameters in the same scope
- C. A function with multiple definitions in different scopes
- D. A function that can be overridden by derived classes
- Answer: B. Multiple functions with the same name and parameters in the same scope

ABSTRACTION

1. What is abstraction in programming?


- A. Hiding the implementation details and showing only the necessary features
- B. Exposing all the details of an implementation
- C. Implementing all features in a single class
- D. Making code more complex for better understanding
- Answer: A. Hiding the implementation details and showing only the necessary features

2. Which keyword is used to declare an abstract class in C++?


- A. abstract
- B. virtual
- C. pure
- D. class
-

Answer: D. class

3. What is the purpose of an abstract class in C++?


- A. To create objects directly
- B. To provide a blueprint for other classes
- C. To implement all methods
- D. To hide all methods
- Answer: B. To provide a blueprint for other classes

4. Can an abstract class have a constructor in C++?


- A. Yes, always
- B. No, never
- C. Yes, but only if it's private
- D. Yes, but only if it's public
- Answer: A. Yes, always

5. Which of the following is true about pure virtual functions in C++?


- A. They have a body in the abstract class
- B. They must be defined in every derived class
- C. They cannot be overridden
- D. They end with the keyword "pure"
- Answer: B. They must be defined in every derived class

6. What is the term for providing a common interface for a group of related classes without
specifying their concrete implementations?
- A. Encapsulation
- B. Inheritance
- C. Abstraction
- D. Polymorphism
- Answer: C. Abstraction

7. In C++, how is abstraction related to encapsulation?


- A. Abstraction is a form of encapsulation
- B. Encapsulation is a form of abstraction
- C. They are unrelated concepts
- D. Abstraction and encapsulation are the same thing
- Answer: A. Abstraction is a form of encapsulation

8. Which of the following is an example of abstraction in C++?


- A. Declaring a variable
- B. Implementing a function
- C. Using a class without knowing its internal details
- D. Writing inline code
- Answer: C. Using a class without knowing its internal details

9. What is the purpose of the keyword `final` in C++ in the context of abstraction?
- A. Marks a class as abstract
- B. Marks a class as non-abstract
- C. Prevents a class from being subclassed
- D. Indicates the end of a class definition
- Answer: C. Prevents a class from being subclassed

10. What is the term for hiding the details of how an object is implemented and only exposing
the necessary interfaces?
- A. Abstraction
- B. Encapsulation
- C. Polymorphism
- D. Inheritance
- Answer: B. Encapsulation

ENCAPSULATION

1. What is encapsulation in C++?


- A. Hiding the implementation details and exposing the necessary features
- B. Exposing all the details of a class
- C. Implementing all features in a single class
- D. Making code more complex for better understanding
- Answer: A. Hiding the implementation details and exposing the necessary features

2. Which keyword is used to declare a private member in a class in C++?


- A. private
- B. protected
- C. public
- D. hidden
- Answer: A. private

3. What is the main purpose of encapsulation in programming?


- A. To increase code complexity
- B. To expose all implementation details
- C. To achieve data hiding and protect data integrity
- D. To make code execution faster
- Answer: C. To achieve data hiding and protect data integrity

4. In C++, can you access private members of a class outside the class?
- A. Yes, always
- B. No, never
- C. Yes, if using friend functions
- D. Yes, if using public functions
- Answer: B. No, never

5. Which concept is closely related to encapsulation?


- A. Polymorphism
- B. Inheritance
- C. Abstraction
- D. Overloading
- Answer: C. Abstraction
6. What is the purpose of the `friend` keyword in C++?
- A. To declare a function as a friend function
- B. To declare a class as a friend class
- C. To allow access to private members from outside the class
- D. All of the above
- Answer: D. All of the above

7. In encapsulation, what is the term used for providing a public method to access private data
members?
- A. Getter method
- B. Setter method
- C. Wrapper method
- D. Encapsulator method
- Answer: A. Getter method

8. What is the potential drawback of using too many friend functions in a class?
- A. Improved encapsulation
- B. Reduced code modularity
- C. Enhanced data hiding
- D. Better code readability
- Answer: B. Reduced code modularity

9. Which access specifier in C++ allows members to be accessed by the derived classes?
- A. public
- B. private
- C. protected
- D. internal
- Answer: C. protected

10. Which principle of object-oriented programming is strongly associated with


encapsulation?
- A. Inheritance
- B. Polymorphism
- C. Abstraction
- D. Encapsulation itself
- Answer: D. Encapsulation itself

OPERATING SYSTEM

1. What is the primary function of an operating system?


- A. Executing user programs
- B. Managing hardware resources
- C. Providing a user interface
- D. Performing data analysis
- Answer: B. Managing hardware resources

2. Which component of an operating system is responsible for managing memory?


- A. Kernel
- B. File System
- C. Memory Manager
- D. Scheduler
- Answer: C. Memory Manager

3. What is the role of the kernel in an operating system?


- A. Managing user interfaces
- B. Handling file operations
- C. Core component for managing hardware and resources
- D. Executing user applications
- Answer: C. Core component for managing hardware and resources

4. Which scheduling algorithm assigns a fixed time unit per process, regardless of its
execution status?
- A. Round Robin
- B. First-Come-First-Serve (FCFS)
- C. Shortest Job Next (SJN)
- D. Priority Scheduling
- Answer: A. Round Robin

5. What is the purpose of the page table in virtual memory management?


- A. To store page contents
- B. To map virtual addresses to physical addresses
- C. To manage file systems
- D. To allocate CPU time to processes
- Answer: B. To map virtual addresses to physical addresses

6. Which memory allocation method allows memory blocks to be allocated and deallocated in
any order, minimizing memory fragmentation?
- A. Fixed Partitioning
- B. Dynamic Partitioning
- C. Paging
- D. Segmentation
- Answer: C. Paging

7. What is the purpose of the device driver in an operating system?


- A. Manage user interfaces
- B. Manage hardware devices
- C. Execute user applications
- D. Handle file operations
- Answer: B. Manage hardware devices

8. Which file system is widely used in Unix and Linux operating systems?
- A. NTFS
- B. FAT32
- C. Ext4
- D. HFS+
- Answer: C. Ext4

9. What is the role of the shell in an operating system?


- A. Manage memory allocation
- B. Provide a user interface for executing commands
- C. Manage file operations
- D. Execute device drivers
- Answer: B. Provide a user interface for executing commands

10. Which process scheduling algorithm gives priority to the process with the highest priority
value?
- A. Round Robin
- B. First-Come-First-Serve (FCFS)
- C. Shortest Job Next (SJN)
- D. Priority Scheduling
- Answer: D. Priority Scheduling

NETWORK OPERATING SYSTEM

1. What is a Network Operating System (NOS)?


- A. An operating system for networking hardware
- B. An operating system that includes networking features
- C. A file system for network storage
- D. A specialized programming language for networking
- Answer: B. An operating system that includes networking features

2. Which characteristic is a key feature of a Network Operating System?


- A. Designed for single-user systems
- B. Focus on individual device management
- C. Emphasis on network resource sharing and management
- D. Limited support for communication between devices
- Answer: C. Emphasis on network resource sharing and management

3. What is the primary goal of a Network Operating System?


- A. Efficient hardware management
- B. Enhanced user interface

- C. Facilitating communication and resource sharing among devices on a network


- D. Maximizing CPU performance
- Answer: C. Facilitating communication and resource sharing among devices on a network

4. Which protocol is commonly used for file sharing in a Network Operating System
environment?
- A. HTTP
- B. FTP
- C. SMTP
- D. SNMP
- Answer: B. FTP

5. What role does a Network Operating System play in user authentication?


- A. It doesn't handle user authentication
- B. It centrally manages user authentication for network resources
- C. It relies on individual devices for user authentication
- D. It focuses on device authentication only
- Answer: B. It centrally manages user authentication for network resources

6. Which NOS model allows users to run applications on a remote server while interacting
with them locally?
- A. Peer-to-Peer (P2P)
- B. Client-Server
- C. Hybrid
- D. Distributed
- Answer: B. Client-Server

7. In a Network Operating System, what is the purpose of a directory service?


- A. Manage network protocols
- B. Provide internet connectivity
- C. Maintain a centralized database of network resources and user information
- D. Manage CPU scheduling
- Answer: C. Maintain a centralized database of network resources and user information

8. Which NOS characteristic ensures data integrity and security during network
communication?
- A. Network Monitoring
- B. Encryption
- C. File Compression
- D. Bandwidth Allocation
- Answer: B. Encryption

9. What is the main advantage of using a Network Operating System in a business


environment?
- A. Increased device autonomy
- B. Simplified hardware management
- C. Enhanced collaboration and resource sharing among users
- D. Limited connectivity between devices
- Answer: C. Enhanced collaboration and resource sharing among users

10. Which type of network is most suitable for a Network Operating System?
- A. Isolated network
- B. Peer-to-peer network
- C. Local Area Network (LAN)
- D. Standalone computer
- Answer: C. Local Area Network (LAN)

DATA STRUCTURES

1. What is a data structure?


- A. A way to store data in a computer
- B. A way to organize and store data for efficient retrieval and modification
- C. A programming language
- D. A hardware component
- Answer: B. A way to organize and store data for efficient retrieval and modification

2. Which data structure follows the Last In, First Out (LIFO) principle?
- A. Queue
- B. Stack
- C. Linked List
- D. Tree
- Answer: B. Stack

3. In data structures, what is the purpose of a linked list?


- A. Efficiently store and retrieve data in a sorted manner
- B. Represent hierarchical relationships between elements
- C. Store data in a linear, non-contiguous fashion
- D. Implement a last-in, first-out structure
- Answer: C. Store data in a linear, non-contiguous fashion

4. Which operation is NOT commonly associated with trees in data structures?


- A. Insertion
- B. Deletion
- C. Sorting
- D. Traversal
- Answer: C. Sorting

5. What is the primary advantage of using a hash table in data structures?


- A. Constant-time search complexity
- B. Efficient handling of dynamic data
- C. Effective sorting of elements
- D. Reduced space complexity
- Answer: A. Constant-time search complexity

6. Which data structure is used for fast retrieval of data from a collection, based on a key?
- A. Array
- B. Stack
- C. Queue
- D. Hash Map
- Answer: D. Hash Map

7. What is the time complexity of searching for an element in a sorted array using binary
search?
- A. O(1)
- B. O(log n)
- C. O(n)
- D. O(n^2)
- Answer: B. O(log n)

8. Which data structure is suitable for implementing undo functionality in applications?


- A. Stack
- B. Linked List
- C. Queue
- D. Hash Table
- Answer: A. Stack

9. What is the primary purpose of a queue in data structures?


- A. To efficiently search for an element
- B. To store elements in a last-in, first-out manner
- C. To store elements in a first-in, first-out manner
- D. To organize elements in a hierarchical structure
- Answer: C. To store elements in a first-in, first-out manner

10. Which data structure is commonly used for representing a hierarchical relationship
between elements?
- A. Linked List
- B. Stack
- C. Queue
- D. Tree
- Answer: D. Tree

ARRAYS

1. What is an array in programming?


- A. A linear data structure
- B. A collection of elements with similar data types
- C. A data structure that follows the LIFO principle
- D. A key-value pair storage structure
- Answer: B. A collection of elements with similar data types

2. What is the index of the first element in an array with n elements?


- A. 0
- B. 1
- C. n
- D. n-1
- Answer: A. 0

3. In C++, how do you declare an array of integers with 5 elements?


- A. `int array[5];`
- B. `array int[5];`
- C. `int[5] array;`
- D. `array[5] int;`
- Answer: A. `int array[5];`

4. What is the time complexity of accessing an element in an array by its index?


- A. O(1)
- B. O(log n)
- C. O(n)
- D. O(n^2)
- Answer: A. O(1)

5. In an array, what is the term used to represent the maximum number of elements it can
hold?
- A. Size
- B. Length
- C. Capacity
- D. Index
- Answer: B. Length

6. Which operation in arrays is used to add an element at the end?


- A. Insert
- B. Append
- C. Push
- D. Extend
- Answer: B. Append

7. What is the term used for an array where elements are stored in contiguous memory
locations?
- A. Linked Array
- B. Contiguous Array
- C. Sequential Array
- D. Random Array
- Answer: C. Sequential Array

8. What is the time complexity of inserting an element at the beginning of an array?


- A. O(1)
- B. O(log n)
- C. O(n)
- D. O(n^2)
- Answer: C. O(n)

9. In arrays, what is the term used for the process of rearranging elements to a more random
order?
- A. Shuffling
- B. Sorting
- C. Reversing
- D. Swapping
- Answer: A. Shuffling

10. Which data structure can be considered as a dynamic version of an array with variable
size?
- A. Linked List
- B. Queue
- C. Array List
- D. Stack
- Answer: C. Array List

STACKS

1. What is a stack in data structures?


- A. A linear data structure
- B. A hierarchical data structure
- C. A network structure
- D. A non-linear data structure
- Answer: A. A linear data structure

2. Which principle does a stack follow for element insertion and removal?
- A. First In, First Out

(FIFO)
- B. Last In, First Out (LIFO)
- C. Random Order
- D. Priority-based Order
- Answer: B. Last In, First Out (LIFO)

3. What is the operation called when an element is added to the top of the stack?
- A. Pop
- B. Push
- C. Insert
- D. Remove
- Answer: B. Push

4. Which operation removes the top element from a stack?


- A. Pop
- B. Push
- C. Insert
- D. Remove
- Answer: A. Pop

5. In a stack, which element is considered as the last one to be added?


- A. Top element
- B. Bottom element
- C. Middle element
- D. Random element
- Answer: A. Top element

6. What is the time complexity of the push operation in a stack?


- A. O(1)
- B. O(log n)
- C. O(n)
- D. O(n^2)
- Answer: A. O(1)

7. Which data structure can be efficiently implemented using a stack?


- A. Queue
- B. Linked List
- C. Tree
- D. Expression Evaluation
- Answer: D. Expression Evaluation

8. What happens when you try to pop an element from an empty stack?
- A. Stack Overflow
- B. Stack Underflow
- C. Memory Leak
- D. Compilation Error
- Answer: B. Stack Underflow
9. In the context of function calls, what does a stack maintain?
- A. Variable declarations
- B. Function parameters
- C. Return addresses
- D. All of the above
- Answer: D. All of the above

10. Which of the following operations is NOT associated with stacks?


- A. Pop
- B. Push
- C. Retrieve
- D. Peek
- Answer: C. Retrieve

QUEUE

1. What is a queue in data structures?


- A. A linear data structure
- B. A hierarchical data structure
- C. A non-linear data structure
- D. A dynamic data structure
- Answer: A. A linear data structure

2. Which principle does a queue follow for element insertion and removal?
- A. First In, First Out (FIFO)
- B. Last In, First Out (LIFO)
- C. Random Order
- D. Priority-based Order
- Answer: A. First In, First Out (FIFO)

3. What is the operation called when an element is added to the rear of the queue?
- A. Pop
- B. Push
- C. Enqueue
- D. Dequeue
- Answer: C. Enqueue

4. Which operation removes an element from the front of the queue?


- A. Pop
- B. Push
- C. Enqueue
- D. Dequeue
- Answer: D. Dequeue

5. In a queue, which element is considered as the first one to be added?


- A. Top element
- B. Bottom element
- C. Front element
- D. Rear element
- Answer: C. Front element
6. What is the time complexity of the enqueue operation in a queue?
- A. O(1)
- B. O(log n)
- C. O(n)
- D. O(n^2)
- Answer: A. O(1)

7. Which data structure can be efficiently implemented using a queue?


- A. Stack
- B. Linked List
- C. Tree
- D. Breadth-First Search (BFS)
- Answer: D. Breadth-First Search (BFS)

8. What happens when you try to dequeue an element from an empty queue?
- A. Queue Overflow
- B. Queue Underflow
- C. Memory Leak
- D. Compilation Error
- Answer: B. Queue Underflow

9. In a priority queue, how are elements arranged for removal based on priority?
- A. In ascending order
- B. In descending order
- C. Based on a fixed order
- D. Based on priority levels assigned to elements
- Answer: D. Based on priority levels assigned to elements

10. Which of the following operations is NOT associated with queues?


- A. Enqueue
- B. Dequeue
- C. Retrieve
- D. Peek
- Answer: C. Retrieve

CIRCULAR LINKED LIST

1. What is a circular linked list?


- A. A list with circular elements
- B. A list where each element points to the next and the last points to the first
- C. A list with elements arranged in a circle
- D. A list with circular references
- Answer: B. A list where each element points to the next and the last points to the first

2. What is the advantage of a circular linked list over a linear linked list?
- A. Simplicity of implementation
- B. Ease of traversal
- C. Ability to efficiently rotate elements
- D. Efficient reversal of elements
- Answer: C. Ability to efficiently rotate elements

3. In a circular linked list, what does the last node point to?
- A. The first node
- B. NULL
- C. The previous node
- D. Itself
- Answer: A. The first node

4. Which operation is used to add a new node at the end of a circular linked list?
- A. Insert
- B. Append
- C. Attach
- D. Connect
- Answer: B. Append

5. What is the time complexity of inserting a node at the beginning of a circular linked list?
- A. O(1)
- B. O(log n)
- C. O(n)
- D. O(n^2)
- Answer: A. O(1)

6. In a doubly circular linked list, each node has a pointer to which nodes?
- A. Only the next node
- B. Only the previous node
- C. Both the next and previous nodes
- D. Neither next nor previous nodes
- Answer: C. Both the next and previous nodes

7. What is the primary challenge in circular linked list implementation?


- A. Difficulty in traversing
- B. Difficulty in insertion
- C. Difficulty in deletion
- D. Difficulty in locating the last node
- Answer: D. Difficulty in locating the last node

8. Which data structure is suitable for representing circular linked lists?


- A. Array
- B. Stack
- C. Pointer
- D. Dynamic Memory Allocation
- Answer: C. Pointer

9. What is the disadvantage of using a circular linked list?


- A. Complexity of implementation
- B. Inability to efficiently rotate elements
- C. Difficulty in reversing elements
- D. Infinite loop possibilities
- Answer: D. Infinite loop possibilities
10. Which of the following operations is NOT associated with circular linked lists?
- A. Traversal
- B. Insertion
- C. Deletion
- D. Sorting
- Answer: D. Sorting

DEQUEUE (DOUBLE-ENDED QUEUE)

1. What does Dequeue stand for?


- A. Double-Ended Queue
- B. Dynamic Queue
- C. Directed Queue
- D. Data Queue
- Answer: A. Double-Ended Queue

2. What is the main characteristic of a Dequeue?


- A. Elements can be added only at one end
- B. Elements can be removed only from one end
- C. Elements can be added or removed from both ends
- D. Elements can be added or removed from the middle
- Answer: C. Elements can be added or removed from both ends

3. Which operation adds an element to the front of a Dequeue?


- A. Front-Enqueue
- B. Front-Push
- C. Front-Insert
- D. Front-Add
- Answer: A. Front-Enqueue

4. What is the time complexity of removing an element from the rear of a Dequeue?
- A. O(1)
- B. O(log n)
-

C. O(n)
- D. O(n^2)
- Answer: A. O(1)

5. In a Dequeue, what happens when you try to remove an element from an empty queue?
- A. Dequeue Overflow
- B. Dequeue Underflow
- C. Memory Leak
- D. Compilation Error
- Answer: B. Dequeue Underflow

6. Which feature of a Dequeue makes it different from a regular queue?


- A. Dynamic size
- B. Priority-based removal
- C. Ability to add or remove elements from both ends
- D. Restricted insertion
- Answer: C. Ability to add or remove elements from both ends

7. What is the primary advantage of using a Dequeue?


- A. Efficient memory usage
- B. Faster insertion at the rear
- C. Ability to efficiently add or remove elements from both ends
- D. Simplicity of implementation
- Answer: C. Ability to efficiently add or remove elements from both ends

8. Which operation is used to check the element at the front of a Dequeue without removing
it?
- A. PeekFront
- B. FrontView
- C. CheckFront
- D. FrontPeek
- Answer: A. PeekFront

9. In a Dequeue, what does the term "circular" refer to?


- A. Circular linked structure
- B. Circular motion of elements
- C. Ability to rotate elements
- D. Continuous addition and removal of elements
- Answer: D. Continuous addition and removal of elements

10. Which of the following operations is NOT associated with a Dequeue?


- A. InsertFront
- B. RemoveRear
- C. Enqueue
- D. Dequeue
- Answer: C. Enqueue

STRINGS

1. What is a string in programming?


- A. A sequence of integers
- B. A sequence of characters
- C. A data type in C++
- D. A mathematical operation
- Answer: B. A sequence of characters

2. In C++, how is a string different from an array of characters?


- A. Strings cannot be modified
- B. Strings can have variable length
- C. Arrays cannot store characters
- D. Arrays are more efficient for character storage
- Answer: B. Strings can have variable length

3. Which header file is used in C++ for string operations?


- A. `<iostream>`
- B. `<cstring>`
- C. `<string>`
- D. `<stdio.h>`
- Answer: C. `<string>`

4. What is the null-terminated character in a C-style string?


- A. '\0'
- B. '\n'
- C. '\t'
- D. '\r'
- Answer: A. '\0'

5. Which function is used to find the length of a string in C++?


- A. `strcat()`
- B. `strlen()`
- C. `strncpy()`
- D. `strchr()`
- Answer: B. `strlen()`

6. Which operator is used for string concatenation in C++?


- A. '+'
- B. '-'
- C. '*'
- D. '/'
- Answer: A. '+'

7. What is the purpose of the `substr` function in C++ strings?


- A. To find the substring in a string
- B. To replace a substring with another substring
- C. To extract a substring from a string
- D. To compare two substrings
- Answer: C. To extract a substring from a string

8. Which function is used to compare two strings in C++?


- A. `strcmp()`
- B. `strcat()`
- C. `strlen()`
- D. `substr()`
- Answer: A. `strcmp()`

9. What is the purpose of the `getline` function in C++?


- A. To read a line of text from the console
- B. To concatenate two lines of text
- C. To remove a line from a string
- D. To find the length of a line
- Answer: A. To read a line of text from the console

10. In C++, how do you convert a string to an integer?


- A. `stoi()`
- B. `itoa()`
- C. `atoi()`
- D. `strtoi()`
- Answer: A. `stoi()`

You might also like