0% found this document useful (0 votes)
29 views39 pages

CS201 Midterm and Finall Term Preparation by ZB

The document is a midterm preparation file for a CS201 course, containing multiple-choice questions (MCQs) covering various programming concepts and data structures. It includes questions on topics such as time complexity, object-oriented programming, data structures, and Python syntax. Each question is followed by the correct answer, providing a resource for students to study for their upcoming exam.

Uploaded by

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

CS201 Midterm and Finall Term Preparation by ZB

The document is a midterm preparation file for a CS201 course, containing multiple-choice questions (MCQs) covering various programming concepts and data structures. It includes questions on topics such as time complexity, object-oriented programming, data structures, and Python syntax. Each question is followed by the correct answer, providing a resource for students to study for their upcoming exam.

Uploaded by

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

Join our WhatsApp channel

https://whatsapp.com/channel/0029VafvOcy90x2tPbUaX02I

MCQS CS201 midterm preparation file ZB

In the name of God , Most


Gracious, Most merciful

CS201

join our WhatsApp channel


https://whatsapp.com/channel/0029VaODheTDp2Q8YVcoON2p
MCQS Midterm preparation file ZB

ZB
MCQS
1. What is the time complexity of accessing an element in an array? a) O(1)
b) O(n)
c) O(log n)
d) O(n^2)
Answer: a) O(1)

2. Which of the following is a valid variable name in most programming languages? a)


1st_variable
b) _variable1
c) @variable
d) variable-1
Answer: b) _variable1

3. What does the term 'encapsulation' refer to in object-oriented programming? a) Hiding


data within a class
b) Sharing data between classes
c) Inheriting properties from a class
d) Overriding methods of a class
Answer: a) Hiding data within a class

4. What is the output of the following code: print(2**3)? a) 8


b) 6
c) 4
d) 3
Answer: a) 8

5. Which of the following is a type of sorting algorithm? a) Queue


b) Merge Sort
c) Stack
d) Tree
Answer: b) Merge Sort
ZB
MCQS ZB
Midterm preparation file

6. Which operator is used to compare equality in most programming languages? a) =


b) ==
c) ===
d) !=
Answer: b) ==

7. What is the primary function of an operating system? a) To compile programs


b) To manage hardware and software resources
c) To design algorithms
d) To store data
Answer: b) To manage hardware and software resources

8. Which of the following is an example of a linked data structure? a) Array


b) Stack
c) Linked List
d) Hash Table
Answer: c) Linked List

9. Which of the following represents the worst-case time complexity of Quick Sort? a)
O(n)
b) O(log n)
c) O(n log n)
d) O(n^2)
Answer: d) O(n^2)

10. What does 'abstraction' allow in object-oriented programming? a) Hiding


unnecessary details
b) Reducing code size
c) Enhancing performance
d) Increasing security
Answer: a) Hiding unnecessary details
MCQS ZB
Midterm preparation file
11. Which data structure uses a LIFO (Last In, First Out) order? a) Queue
b) Stack

ZB
c) Linked List
d) Array
Answer: b) Stack

12. Which of the following is a feature of a binary search tree? a) Every node has
two children
b) The left child is always greater than the parent
c) The right child is always smaller than the parent
d) Nodes are ordered in a way that every left child is smaller than the parent and
every right child is greater.
Answer: d) Nodes are ordered in a way that every left child is smaller than the
parent and every right child is greater.

13. Which keyword is used to define a function in Python? a) function


b) def
c) fun
d) func
Answer: b) def

14. Which of the following is a valid way to declare a constant in Python? a) const x
= 10
b) final x = 10
c) x = 10
d) Python does not have constants
Answer: d) Python does not have constants

15. Which of the following is an example of an infinite loop? a) for i in range(10):


b) while True:
c) for i in range(10, 20):
d) while i < 10:
Answer: b) while True:
MCQS Midterm preparation file

ZB
16. In which of the following algorithms, a divide and conquer approach is used? a) ZB
Quick Sort
b) Bubble Sort
c) Selection Sort
d) Insertion Sort
Answer: a) Quick Sort

17. Which of the following best describes the purpose of a constructor in a class? a)
It defines a method to delete the object
b) It initializes the object's attributes
c) It defines the class's behavior
d) It checks if the object is valid
Answer: b) It initializes the object's attributes

18. Which data structure is most suitable for implementing recursion? a) Queue
b) Stack
c) Linked List
d) Array
Answer: b) Stack

19. Which of the following sorting algorithms has the best average-case time
complexity? a) Selection Sort
b) Bubble Sort
c) Merge Sort
d) Quick Sort
Answer: c) Merge Sort

20. Which of the following is not a valid data type in Python? a) int
b) float
c) character
d) string
Answer: c) character
MCQS MIDTERM PREPARATION FILE ZB

21. Which function is used to obtain the length of a list in Python? a) length()

b) len()

ZB
c) size()

d) count()

Answer: b) len()

22. Which of the following is a type of loop used in programming? a) for loop

b) while loop

c) do-while loop

d) All of the above

Answer: d) All of the above

23. In which data structure does each element have a unique identifier? a) List

b) Set

c) Dictionary

d) Queue

Answer: c) Dictionary

24. Which of the following is true about Python's list? a) Lists are immutable

b) Lists can only contain numbers

c) Lists can contain elements of different data types

d) Lists are faster than arrays

Answer: c) Lists can contain elements of different data types

25. Which of the following is a method of adding an element to a list in Python? a)

add()

b) append()

c) insert()

d) All of the above

Answer: d) All of the above


ZB
ZB
MCQS Midterm preparation file

26. Which of the following is an example of polymorphism? a) Multiple classes


inheriting the same method
b) Different classes defining methods with the same name
c) A class overriding a method of the parent class
d) All of the above
Answer: d) All of the above

27. Which of the following functions is used to sort a list in Python? a) sort()
b) order()
c) organize()
d) sorted()
Answer: a) sort()

28. Which of the following is an example of a primary memory? a) Hard Drive


b) RAM
c) SSD
d) Flash Drive
Answer: b) RAM

29. Which of the following best describes an abstract class in OOP? a) A class
with no methods
b) A class that can be instantiated
c) A class that cannot be instantiated but can be inherited
d) A class that does not require constructors
Answer: c) A class that cannot be instantiated but can be inherited

30. What does the 'return' statement do in a function? a) Ends the function
without returning a value
b) Terminates the program
c) Returns a value and exits the function
d) None of the above
Answer: c) Returns a value and exits the function
ZB
MCQS ZB

Midterm preparation file


31. Which of the following best describes the Big O notation? a) The measure of how long

an algorithm takes to run

b) The space complexity of an algorithm

c) The measure of an algorithm's worst-case execution time

d) The exact time an algorithm will take

Answer: c) The measure of an algorithm's worst-case execution time

32. Which of the following is used to handle exceptions in Python? a) catch

b) error

c) try-except

d) assert

Answer: c) try-except

33. What is the time complexity of Bubble Sort in the worst case? a) O(n)

b) O(n^2)

c) O(log n)

d) O(n log n)

Answer: b) O(n^2)

34. Which of the following is a method to remove the last element of a list in Python? a)

pop()

b) delete()

c) remove()

d) discard()

Answer: a) pop()

35. Which of the following data structures uses a FIFO (First In, First Out) order? a) Queue

b) Stack

c) Linked List

d) Tree

Answer: a) Queue
MCQS ZB

ZB
Midterm preparation file
36. Which of the following is not a built-in Python data structure? a) List

b) Dictionary

c) Tree

d) Set

Answer: c) Tree

37. Which algorithm is used for finding the shortest path in a graph? a) Bubble Sort

b) Quick Sort

c) Dijkstra's Algorithm

d) Merge Sort

Answer: c) Dijkstra's Algorithm

38. What is the time complexity of accessing an element in a linked list? a) O(1)

b) O(n)

c) O(log n)

d) O(n^2)

Answer: b) O(n)

39. Which of the following best describes the concept of inheritance in object-oriented

programming? a) Reusing the implementation of an existing class

b) Hiding details of a class

c) Creating a new class without using any existing class

d) Changing the data members of an existing class

Answer: a) Reusing the implementation of an existing class

40. Which of the following is a valid syntax to define a function in Python that takes two

parameters? a) def function(a, b):

b) function def(a, b):

c) function(a, b) = def:

d) def function = (a, b):

Answer: a) def function(a, b):


ZB
MCQS

ZB
Midterm preparation file
41. Which of the following is an example of a class method in Python? a)
@staticmethod
b) @classmethod
c) @method
d) def method()
Answer: b) @classmethod

42. Which of the following methods adds an element to the beginning of a list in
Python? a) append()
b) insert()
c) push()
d) add()
Answer: b) insert()

43. What is the time complexity of accessing an element in a hash table? a) O(1)
b) O(n)
c) O(log n)
d) O(n^2)
Answer: a) O(1)

44. Which of the following operators is used to combine two lists in Python? a) +
b) -
c) *
d) &
Answer: a) +

45. Which of the following sorting algorithms is considered the fastest in average
cases? a) Selection Sort
b) Quick Sort
c) Merge Sort
d) Bubble Sort
Answer: b) Quick Sort
ZB

ZB
MCQS
Midterm preparation file
46. Which of the following is the correct way to create a dictionary in Python? a)
dict = {1: 'apple', 2: 'banana'}
b) dict = (1: 'apple', 2: 'banana')
c) dict = [1: 'apple', 2: 'banana']
d) dict = {1, 'apple', 2, 'banana'}
Answer: a) dict = {1: 'apple', 2: 'banana'}

47. Which function is used to find the maximum value in a list in Python? a) max()
b) highest()
c) largest()
d) get_max()
Answer: a) max()

48. Which of the following is not a valid way to create a loop in Python? a) for i in
range(10):
b) while i < 10:
c) repeat i until 10:
d) while True:
Answer: c) repeat i until 10:

49. Which of the following methods removes an element from a list in Python? a)
remove()
b) pop()
c) discard()
d) delete()
Answer: a) remove()

50. Which of the following is a correct implementation of an if-else statement in


Python? a) if x > 10 { print("x is greater") }
b) if (x > 10): print("x is greater")
c) if x > 10: { print("x is greater") }
d) if x > 10: print("x is greater") else print("x is smaller")
Answer: d) if x > 10: print("x is greater") else print("x is smaller")
ZB

ZB
MCQS
Midterm preparation file
51. Which data structure does the 'pop()' function belong to? a) Queue
b) Stack
c) Linked List
d) Dictionary
Answer: b) Stack

52. Which of the following statements is true about a hash table? a) Hash tables store elements in a
sorted order
b) Hash tables have fast access times for searches
c) Hash tables only allow unique keys
d) Both b and c
Answer: d) Both b and c

53. Which of the following is true about recursion? a) A recursive function must always call itself
twice
b) Recursive functions must have a base case to prevent infinite recursion
c) Recursion is slower than iteration
d) All recursive functions are always optimized
Answer: b) Recursive functions must have a base case to prevent infinite recursion

54. Which of the following is used to break out of a loop in Python? a) exit()
b) break
c) stop
d) return
Answer: b) break

55. Which of the following best describes an adjacency matrix in graph theory? a) A matrix where
each element represents the weight of an edge
b) A list of all vertices
c) A list of connected nodes only
d) A 2D array that represents the connections between nodes in a graph
Answer: d) A 2D array that represents the connections between nodes in a graph
MCQS Midterm preparation file ZB
56. Which of the following is true about Python's dictionaries? a) They are ordered
collections
b) They store key-value pairs
c) Keys in a dictionary must be mutable
d) None of the above
Answer: b) They store key-value pairs

57. Which of the following is a common use of a stack? a) Undo functionality in text
editors
b) Calculations in arithmetic expressions
c) Both a and b
d) Sorting a list
Answer: c) Both a and b

58. What does the 'del' statement do in Python? a) Deletes an element from a list
b) Deletes a variable
c) Deletes an entire dictionary
d) All of the above
Answer: d) All of the above

59. What is the main characteristic of a heap data structure? a) It is an unordered


collection
b) It is a balanced tree with no child node greater than the parent
c) It maintains a strict order between children and parents
d) It stores only integers
Answer: c) It maintains a strict order between children and parents

60. Which of the following is used to define a class in Python? a) class MyClass:
b) MyClass class:
c) class = MyClass
d) def MyClass:
Answer: a) class MyClass:
ZB
MCQS Midterm preparation file

61. What is the time complexity of the merge operation in Merge Sort? a) O(1)
b) O(n)
c) O(n log n)
d) O(n^2)
Answer: b) O(n)

62. Which of the following is a primary characteristic of a queue? a) Last In First Out (LIFO)
b) First In First Out (FIFO)
c) It is unordered
d) It allows random access to elements
Answer: b) First In First Out (FIFO)

63. Which of the following best describes the purpose of a hash function in a hash table? a) To
retrieve values quickly
b) To compute the index for a given key
c) To check for duplicate keys
d) To ensure keys are unique
Answer: b) To compute the index for a given key

64. Which of the following is true about a doubly linked list? a) It can only be traversed in one
direction
b) It stores two pointers per node, one to the next and one to the previous node
c) It is faster than a singly linked list
d) It does not support deleting elements efficiently
Answer: b) It stores two pointers per node, one to the next and one to the previous node

65. Which of the following is not a valid Python loop? a) for i in range(5):
b) while x > 10:
c) do while x < 5:
d) None of the above
Answer: c) do while x < 5:
MCQS Midterm preparation file ZB
66. What is the purpose of the 'finally' block in exception handling in Python? a) To catch
exceptions
b) To execute code after a try block regardless of whether an exception was raised
c) To re-raise an exception
d) To define default exception handling
Answer: b) To execute code after a try block regardless of whether an exception was raised

67. Which of the following sorting algorithms is considered stable? a) Quick Sort
b) Heap Sort
c) Merge Sort
d) Selection Sort
Answer: c) Merge Sort

68. Which of the following is true about a binary search tree? a) The left child is always
greater than the parent
b) The right child is always smaller than the parent
c) Both the left and right subtrees are binary search trees
d) Binary search trees are unbalanced
Answer: c) Both the left and right subtrees are binary search trees

69. What does the term 'polymorphism' refer to in object-oriented programming? a)


Reusing a class's methods
b) The ability to inherit from multiple classes
c) A method or operator behaving differently based on the data type of the object
d) Hiding the implementation details of a class
Answer: c) A method or operator behaving differently based on the data type of the object

70. Which of the following is true about Python dictionaries? a) Keys must be mutable
b) They are ordered collections of key-value pairs
c) Values must be unique
d) They do not allow duplicate keys
Answer: d) They do not allow duplicate keys
MCQS
Midterm preparation file ZB

71. What is the time complexity of finding the maximum element in an


unsorted array? a) O(1)
b) O(log n)
c) O(n)
d) O(n^2)
Answer: c) O(n)

72. What does the 'break' statement do in a loop? a) Exits the loop entirely
b) Skips the current iteration and continues to the next one
c) Stops the program execution
d) Resets the loop variable
Answer: a) Exits the loop entirely

73. Which of the following is an example of a recursive function? a) A function


that calls itself
b) A function that iterates over a loop
c) A function that does not return any value
d) A function that sorts data
Answer: a) A function that calls itself

74. Which of the following is the correct way to create a set in Python? a) set =
[1, 2, 3]
b) set = (1, 2, 3)
c) set = {1, 2, 3}
d) set = <1, 2, 3>
Answer: c) set = {1, 2, 3}

75. What is the result of applying the '==' operator in Python? a) It checks if two
variables are the same object
b) It checks if two variables have the same value
c) It assigns one variable to another
d) It compares the data types of two variables
Answer: b) It checks if two variables have the same value
MIDTERM Important topic from 1
to 22 lectures

1. Basics of Programming
Introduction to programming languages (C++, Python, or Java, depending on the
course).
Syntax and semantics of the chosen programming language.
Writing and understanding simple programs.

2. Variables and Data Types


Primitive data types (int, float, char, etc.).
Constants and literals.
Type conversion (implicit and explicit).

3. Control Structures
Conditional statements (if, if-else, switch).
Looping structures (for, while, do-while).
Nested loops and control statements like break and continue.

4. Functions
Function declaration, definition, and calling.
Parameter passing (by value and by reference).
Scope of variables (local vs global).
Recursion basics.

5. Arrays
Declaration and initialization.
Single-dimensional and multi-dimensional arrays.
Traversing and basic operations on arrays.

6. Pointers (If Covered)


Basics of pointers and memory addresses.
Pointer arithmetic.
Pointers and arrays.

7. Basic Input/Output
cin and cout (in C++) or equivalent functions in other languages.
File handling basics (if included).

8. Debugging and Problem-Solving


Identifying logical and syntax errors.
Algorithmic thinking.

Study Tips:
Review lecture slides, assignments, and practice questions.
Focus on solving past papers and sample questions.
Understand how to trace code manually.
MIDTERM important topic ZB

9. Operators
Arithmetic, relational, and logical operators.
Bitwise operators (if included).
Operator precedence and associativity.

10. Strings

String handling (character arrays or string objects, depending on the language).


Basic string operations: concatenation, comparison, length, and manipulation.

11. Classes and Objects (Intro to OOP)

Basic understanding of Object-Oriented Programming concepts (if included).

Defining classes and creating objects.


Access modifiers (public, private).

12. Dynamic Memory Allocation

Basics of new and delete (in C++) or equivalents in other languages.


Common pitfalls like memory leaks.

13. Structures

Definition and usage of structures.


Accessing and modifying structure members.
Arrays of structures.

14. Searching and Sorting Algorithms


Linear search and binary search.
Basic sorting techniques (bubble sort, selection sort).

15. Error Handling


Exception handling basics (try-catch blocks).

Common runtime errors and how to prevent them.

16. Best Coding Practices


Importance of comments and readability.

Modular programming and code reuse.


Debugging techniques and using IDE tools effectively.
Finall term preparation

"Marks ka tension? Bas


apne dil ko samjhao: 'Main
genius hoon!'"
Final term preparation ZB
Mcqs

1. Which of the following is a valid C++ data type?


a) int
b) float
c) char
d) All of the above
Answer: d) All of the above

2. What is the size of an int data type in C++?


a) 2 bytes
b) 4 bytes
c) 8 bytes
d) Depends on the compiler
Answer: d) Depends on the compiler

3. Which of the following operators is used to access members of a structure?


a) . (dot operator)
b) -> (arrow operator)
c) : (colon)
d) None of the above
Answer: a) . (dot operator)

4. What is the output of cout << 2 + 3 * 4;?


a) 20
b) 14
c) 12
d) None of the above
Answer: b) 14

5. Which function is used to allocate memory dynamically in C++?


a) malloc()
b) new
c) calloc()
d) None of the above
Answer: b) new
MCQS ZB
Final term preparation

6. What does the keyword return do in a function?

a) Ends the program

b) Exits the function

c) Returns a value to the caller

d) Both b and c

Answer: d) Both b and c

7. What is the default return type of the main() function in C++?

a) void

b) int

c) float

d) char

Answer: b) int

8. Which of the following loops is guaranteed to execute at least once?

a) for loop

b) while loop

c) do-while loop

d) None of the above

Answer: c) do-while loop

9. How do you declare a pointer in C++?

a) int* ptr;

b) int ptr*;

c) int ptr;

d) None of the above

Answer: a) int ptr;

10. What is a constructor in C++?

a) A function with the same name as the class

b) Automatically called when an object is created

c) Initializes class members

d) All of the above

Answer: d) All of the above


MCQS final term preparation ZB

11. What is the purpose of the virtual keyword in C++?


a) Define virtual functions
b) Enable polymorphism
c) Both a and b
d) None of the above
Answer: c) Both a and b

12. Which header file is required for file handling in C++?


a) iostream
b) fstream
c) stdlib.h
d) string
Answer: b) fstream

13. What is the purpose of this pointer in C++?


a) Points to the current object
b) Points to the class name
c) Stores memory address
d) None of the above
Answer: a) Points to the current object

14. What does the statement delete ptr; do?


a) Deallocates memory pointed to by ptr
b) Deletes the pointer variable
c) Both a and b
d) None of the above
Answer: a) Deallocates memory pointed to by ptr

15. What is the time complexity of binary search in the worst case?
a) O(1)
b) O(n)
c) O(log n)
d) O(n^2)
Answer: c) O(log n)
Mcqs Final term preparation ZB

16. Which of the following is not a valid C++ keyword?


a) public
b) friend
c) virtual
d) get
Answer: d) get

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


a) Allocate memory
b) Release resources
c) Modify class properties
d) All of the above
Answer: b) Release resources

18. How do you create an array of integers dynamically?


a) int* arr = new int[size];
b) int arr = new int[size];
c) int arr[size];
d) None of the above
Answer: a) int arr = new int[size];*

19. Which type of inheritance is shown in the following code?


class A {}; class B : public A {};
a) Single inheritance
b) Multiple inheritance
c) Multilevel inheritance
d) None of the above
Answer: a) Single inheritance

20. What does cin represent in C++?


a) Input stream
b) Output stream
c) Error stream
d) None of the above
Answer: a) Input stream
ZB
Mcqs Final term preparation
21. Which of the following is used to include a library in C++?

a) #import

b) #include

c) #library

d) None of the above

Answer: b) #include

22. What is the output of sizeof(char) in C++?

a) 1

b) 2

c) 4

d) 8

Answer: a) 1

23. Which operator is overloaded for object comparison in C++?

a) ==

b) >

c) !=

d) All of the above

Answer: d) All of the above

24. Which feature of OOP allows functions with the same name but different parameters?

a) Encapsulation

b) Polymorphism

c) Inheritance

d) None of the above

Answer: b) Polymorphism

25. What does endl do in C++?

a) Ends a program

b) Inserts a newline character

c) Ends a statement

d) None of the above

Answer: b) Inserts a newline character


Mcqs Final term preparation ZB

26. Which loop executes the most times for a nested loop structure?
a) Outer loop
b) Inner loop
c) Both execute equally
d) None of the above
Answer: b) Inner loop

27. Which of the following is not a valid variable name in C++?


a) _var
b) 2var
c) var_2
d) None of the above
Answer: b) 2var

28. What does the friend keyword do?


a) Gives access to private and protected members
b) Defines friendship between two objects
c) Makes classes unrelated
d) None of the above
Answer: a) Gives access to private and protected members

29. How do you define a constant variable in C++?


a) const int x = 10;
b) constant int x = 10;
c) define x = 10;
d) None of the above
Answer: a) const int x = 10;

30. What does the # symbol indicate in C++?


a) Preprocessor directive
b) A comment
c) End of program
d) None of the above
Answer: a) Preprocessor directive
Mcqs
Final term preparation
31. Which operator is used for bitwise AND in C++?
a) &&
b) &
c) |
d) None of the above
Answer: b) &

32. What is the value of true in C++?


a) 0
b) 1
c) -1
d) None of the above
Answer: b) 1
33. What is the default value of a local variable in C++?
a) 0
b) Garbage value
c) NULL
d) Depends on the compiler
Answer: b) Garbage value

34. Which of the following is used to terminate a C++ statement?


a) : (colon)
b) ; (semicolon)
c) . (dot)
d) None of the above
Answer: b) ; (semicolon)

35. What will be the result of the expression 10 % 3 in C++?


a) 0
b) 1
c) 2
d) None of the above
Answer: b) 1
Mcqs
Final term preparation
36. Which of the following correctly defines a class in C++?
a) class A {}
b) A class {}
c) class: A {}
d) None of the above
Answer: a) class A {}`

37. What is the output of the expression 5 << 2 in C++?


a) 10
b) 20
c) 15
d) 25
Answer: b) 20

38. Which operator is used to resolve the scope of a variable?


a) . (dot)
b) :: (scope resolution)
c) -> (arrow)
d) None of the above
Answer: b) :: (scope resolution)

39. What will ++*p; do if p is a pointer to an integer?


a) Increments the value stored at the address pointed by p
b) Increments the address stored in p
c) Both a and b
d) None of the above
Answer: a) Increments the value stored at the address pointed by p

40. How many objects can be created from a single class in C++?
a) One
b) Two
c) Unlimited
d) None of the above
Answer: c) Unlimited
Mcqs Final term preparation ZB

41. Which function is automatically called when an object is destroyed in


C++?
a) Constructor
b) Destructor
c) Finalizer
d) None of the above
Answer: b) Destructor

42. What does the const keyword signify when used with a function?
a) The function cannot be overridden
b) The function cannot modify class members
c) The function is private
d) None of the above
Answer: b) The function cannot modify class members

43. What is the use of #define in C++?


a) Declare a constant
b) Define a macro
c) Include a library
d) None of the above
Answer: b) Define a macro

44. What is a virtual function in C++?


a) A function without a body
b) A function defined in the base class that can be overridden
c) A function declared using the friend keyword
d) None of the above
Answer: b) A function defined in the base class that can be overridden

45. What is the purpose of try-catch in C++?


a) To handle errors
b) To perform iterations
c) To create constructors
d) None of the above
Answer: a) To handle errors
Mcqs Final term preparation
ZB
46. What does public: mean in a class?
a) Members are accessible only inside the class
b) Members are accessible everywhere
c) Members are accessible only by derived classes
d) None of the above
Answer: b) Members are accessible everywhere

47. What will happen if you call delete on a NULL pointer?


a) Crashes the program
b) Throws an exception
c) Does nothing
d) None of the above
Answer: c) Does nothing

48. What is an abstract class in C++?


a) A class with at least one virtual function
b) A class with all virtual functions
c) A class with at least one pure virtual function
d) None of the above
Answer: c) A class with at least one pure virtual function

49. How do you make a member function constant in C++?


a) Add const before the function name
b) Add const after the function declaration
c) Use the constant keyword
d) None of the above
Answer: b) Add const after the function declaration

50. What is the time complexity of linear search?


a) O(1)
b) O(n)
c) O(log n)
d) O(n^2)
Answer: b) O(n)
Mcqs ZB
Final term preparation

51. How do you handle exceptions in C++?


a) Using try and catch blocks
b) Using if-else statements
c) Using while loops
d) None of the above
Answer: a) Using try and catch blocks

52. Which keyword is used to define inheritance in C++?


a) extends
b) : (colon)
c) inherits
d) None of the above
Answer: b) : (colon)

53. What is a shallow copy in C++?


a) Copying only data members
b) Copying only pointers and not data
c) Copying everything
d) None of the above
Answer: b) Copying only pointers and not data

54. Which operator is used to overload the insertion operator (<<)?


a) operator>>
b) operator<<
c) operator==
d) None of the above
Answer: b) operator<<

55. Which of the following is true about an inline function?


a) It improves performance
b) It reduces function call overhead
c) It may increase code size
d) All of the above
Answer: d) All of the above
Mcqs
Finall term preparation ZB
56. What is the purpose of the protected access specifier?
a) Accessible only inside the class
b) Accessible in the class and derived classes
c) Accessible everywhere
d) None of the above
Answer: b) Accessible in the class and derived classes

57. Which of the following is a preprocessor directive?


a) #include
b) #define
c) Both a and b
d) None of the above
Answer: c) Both a and b

58. What does a pointer store in C++?


a) Address of another variable
b) Value of another variable
c) Size of a variable
d) None of the above
Answer: a) Address of another variable

59. What does break do in a loop?


a) Terminates the loop
b) Skips an iteration
c) Exits the program
d) None of the above
Answer: a) Terminates the loop

60. What is the return type of the main() function in modern C++?
a) void
b) int
c) string
d) char
Answer: b) int
ZB
MCQS ZB
Midterm preparation file

ZB +92 300 5427579


WhatsApp:
https://whatsapp.com/channel/002
9VaODheTDp2Q8YVcoON2p
Second WhatsApp channel
channel on WhatsApp:
https://whatsapp.com/channel/002
9VafvOcy90x2tPbUaX02I
YouTube:
https://youtu.be/-AMj4iNz0UE?
si=hg29pJZ1kujzg57J

Phone no : +92 300 5427579


Phone no: +92 330 3869586
Email: [email protected]
VU Examination Software Demo:
This Online Demo allows students to get themselves familiar with VU Examination Software and it's
available
features. This will help students to attempt their paper conveniently under real time environment.
Click this link:
https://qb.vu.edu.pk/Vutes_demo/default.aspx
Virtual University Official website:
Click this link:
https://www.vu.edu.pk/

Software / Tools:
Is drive m vu k related sb k sb software add hain jin ko kio bhi
software ki zaroorat hai tu wo is link ko click kr
k download kr sakty hain.
Mega drive:
https://mega.nz/folder/tA5x1LYa#9QpZ11pGc9jERh16nJduKg
Note:
Is file m kisi bhi kisam ka kio bhi virus nahi hai sb safe hai aur sb
software/tools sirf PC/laptop k liye hain.

Join our WhatsApp channel for more


https://whatsapp.com/channel/0029VaODheTDp2Q8YVcoON2p
second WhatsApp channel
https://whatsapp.com/channel/0029VafvOcy90x2tPbUaX02I
ZB
MCQS Midterm preparation file

Passing criteria of this course

ZB
Passing Criteria for a Course:

The passing criteria is defined in such a way that it ensures the


student shall be consistent in his studies
throughout the semester.
Therefore, for passing a course/subject, student shall fulfill the
following:
a) Secure minimum 20% score in Formative Assessments/Mid
terms
b) Secure minimum 20% score in Final Term Examinations.
c) Secure at least 40% marks in aggregate while fulfilling the
above requirements
ZB

ZB
MCQS Midterm preparation file

Course Selection and Credit Hours

Q: How do I select courses when the course selection is open?


A: Follow these steps:
1. Check the credit hours allowed by your university (e.g., 21, 18, or 15
credit hours).
2. Each subject typically has 3 credit hours.
3. Divide the total allowed credit hours by 3 to determine how many
subjects you can select.
Examples:
21 credit hours = 7 su18 credit hours = 6 subjects
15 credit hours = 5 subjects
Remember, the university may allow different credit hours for each
student, so check your specific allowance.
By following these steps, you can make informed decisions during
course selection and manage your credit hours
effectively.

ZB

Advice
Hmaesha relax ho ke parha kryn panic mat hua kryn apky
parents ky bohat khawab hoty hn wo pura krny ki puri koshish
kea kryn kbi b ksi pe depend na kea kryn apko bs ak insan
success kr saqta ha or wo insan ap khud hn apky elawa koi nahe
ap bs koshish kryn Allah pak pe strong yakeen rakha kryn or
mehnat krke sb Allah ke hawaly kr dea kryn everything is
possible be brave be strong stay blessed
Hum insan hamesha moat se darty or bhagty hn or moat se
bachny ki koshish krty hn jabke moat ny ana hi ana ha hum
ZB
moat se nahe bach saqty humy jahanam se bachny ki koshish
krni chaheay hum jahanam se bach saqty hn
Insan ko 3 chezo se dar lagta ha Moat Risk/Dolat Ezat Shohrat
Fame

Moat
Humy pta hona chaheay Moat tab ani ha jab Allah
chahy us se pehly puri dunya bi ak tararf ho ke apko
marna chahy to apka kuch nahe beggar saqti

Risk/Dolat
Risk Dolat sb Allah pak ke hath m ha puri dunya ak
taraf b ho jay na apsy apka risk cheen saqti ha na de
saqti ha Ye sirf ALLAh pak ky hath m ha

Izat Zilat shohrat Fame


Izat Zilat Sirf Allah de saqty hn puri dunya mel ke b
apko zra brabr b demage nahe kr saqti Agr ALLAH
Apko izat dena chahay to puri dunya ak tararf ho ke
b apko 1% b nuksan nahe pohancha saqti
Phr Dar ks bat ka ???????????????
Be brave be strong Just put your trust To ALLAH
Hamesha Confident or himat se raho kbi ksi k samne
mat jhuko puri dunya mel k b apka kuch b nahe
beggar saqti
Tips

Payary Students kbi b Only files pe depend mat kea kryn just files read krke uspe
total depend krna it's not Good Vu ke tamat Papers Conceptual hoty hn Agr apky
concepts

Apny concepts clear kryn or handout ko read kryn

Agr Handouts lengthy


Lgy to Ap har topics Ki basic definitions dekh lea kryn or headings dekh leay kryn

Ap thori se mehnat Kryn bs ap kbi b fail nahe hongy jab himat haar jao to un maa
baap k bare m socha kro Jo apki fees dete hn jinko ap pe bohat dawy hn Jo har
jga kehty hn Hamara bacha university Mai parh rha ha un maa baap ki umeedy
Kahi mat Tory apny kea naa Sahi apny maa baap k leay mehnat kro himat kro
Everything is possible just do it my Family
Apko Kuch b samj naa ay yaa ap Kuch b pochna chahy to ap mujsy contact kr
saqty hn

> ZB

ZB

Mri tamaat files Assignment GDB Solutions files Quiz etc.


A to Z Sb free of cost ha Vu k bohat se log mere name pe
passy lete hn Mera unsy koi lena dena nahe so be aware
from them ZB Jo b krta ha Allah ki mehlok ki khudtam k
leay krta ha I don't need anything from anyone in return
because I am doing this business with My Allah
ZB
ZB
MY REQUEST FROM ALL OF YOU

ZB Request from All of you My family


Mjy ap sbki help or support ki zarort ha or wo ye k hum sb Mel
kr Allah ka Quran ki Urdu translation logo tak pohanchy or
Quran ko samjna asaaan kryn dosro k leay sb tak Allah ka Quran
pohanchy it's my compaign hum log 70+ age k ho jaty hn phr b
hmy namaz tak ki translation nahe pta hoti k hum Allah pak se

Kya Dua kr rhy hn so hum youngster's ko Mel kr puri takat or


energy ke sath Allah ka Quran spread krna ha
Hum puri Koshish kr rhy hn k hum sb Mel k Quran ki
translation or most important topics ko maximum share kry with
translation hmara maksad Quran ko spread krna ha be a part of
us
m apni pocket se ye sb kr rha ho Allah ka Quran spread krny k
leay apne or mene sbny Marna ha ak din to q na Allah k leay
Kuch kryn apni energies apni power ko bajay negative use krny k
Allah k leay invest kryn khud ko be a part of us
Agr m 23 ki age m apny sare sources use kr rha ho pocket se
heavy amounts give away kr rha ho Quran spread krny k leay to
ap just share to kr saqty hn itna e krdyn

Contact ZB +92 300 5427579

ZB
Agr ap mujsy contact na kr sky too b ap jo b hn jaha bi hn waha
Allah ka quran pheelay zada se zada with urdu translation jitni
himat ha utna share kryn
ZB
MY Family
Dear students, all Virtual University groups, from A to Z,
have been created by students themselves. Virtual
University does not have any official groups. If anyone
claims their group is official, they are fake. Please be
cautious. Virtual University has not yet made any
announcement regarding an official WhatsApp group.

AL-Quran

"And indeed, with hardship comes ease." (Quran 94:5)


Remember, I'm here to support you! Stay brave and strong!"

May Allah bless you

You might also like