COS 221
Computer programming II
COMPREHENSIVE GENERAL
PASS QUESTIONS ON ALL
TOPICS OF 2ND SEMESTER.
Generated and formatted by
T & M MULTIFUNCTIONAL
BUSINESS VENTURE, LASUED
MAIN CAMPUS.
Generated and formatted by
T & M MULTIFUNCTIONAL BUSINESS VENTURE, LASUED MAIN CAMPUS.
Java Programming, Problem Solving, and OOP. C) The method is empty
Part 1: Java Fundamentals & Syntax D) The method is private
1. What is the role of the Java Virtual Machine (JVM)? Answer: B
A) To compile source code into machine code 9. Which class is used to read user input from the
B) To run bytecode, making Java platform-independent keyboard?
C) To design algorithms A) System
D) To manage hardware directly B) Scanner
Answer: B C) Input
2. In a Java program, where does execution start? D) Printer
A) Inside the class declaration Answer: B
B) At the first import statement 10. What happens if you miss a semicolon at the end of a
C) The main() method Java statement?
D) Inside a loop A) The program runs but ignores that line
Answer: C B) The JVM adds it automatically
3. Which of these is a valid variable name in Java? C) A syntax error occurs during compilation
A) 1stScore D) The program runs slowly
B) class Answer: C
C) $student_Salary ## Part 2: Control Flow & Logic
D) total Amount 11. Which operator is used to check for equality in a
Answer: C comparison?
4. What is the result of the expression 10 % 3? A) =
A) 3 B) ==
B) 1 C) !=
C) 0 D) ===
D) 3.33 Answer: B
Answer: B 12. For the logical AND operator (&&) to return true:
5. Assigning an int to a double (e.g., double y = 5;) is an A) At least one condition must be true
example of: B) Both conditions must be true
A) Explicit Casting C) Both conditions must be false
B) Implicit Casting (Widening) D) Only the first condition must be true
C) Narrowing Answer: B
D) Error 13. What is the output of: int i = 1; while (i < 3) {
Answer: B [Link](i); i++; }?
6. Which keyword makes a variable’s value unchangeable A) 123
(constant)? B) 12
A) static C) 1
B) final D) 23
C) constant Answer: B
D) fixed 14. Which control statement is best for choosing between
Answer: B multiple discrete values?
7. Which of these is a non-primitive (reference) data type? A) if-else
A) int B) switch
B) String C) while
C) boolean D) for
D) char Answer: B
Answer: B 15. What is the purpose of the break statement in a switch
8. What does the void keyword in a method signature case?
mean? A) To restart the program
A) The method returns an integer B) To exit the switch block and prevent "fall-through"
B) The method returns no value C) To skip one loop iteration
Generated and formatted by
T & M MULTIFUNCTIONAL BUSINESS VENTURE, LASUED MAIN CAMPUS.
D) To pause the program C) A type of compiler
Answer: B D) A logical operator
16. How do you write a multi-line comment in Java? Answer: B
A) // comment 24. Which pillar refers to "hiding data" and restricting
B) / comment / direct access?
C) # comment A) Inheritance
D) -- comment B) Polymorphism
Answer: B C) Encapsulation
17. Which loop is ideal when you know exactly how many D) Abstraction
times it should run? Answer: C
A) while loop 25. "Inheritance" allows a class to:
B) do-while loop A) Hide its methods
C) for loop B) Reuse code by acquiring properties from a parent
D) if statement class
Answer: C C) Change its data type
18. The operator != stands for: D) Run on any OS
A) Equal to Answer: B
B) Greater than 26. Which pillar is defined as "one method, many forms"?
C) Not equal to A) Encapsulation
D) Logical NOT B) Abstraction
Answer: C C) Polymorphism
19. What does "Case-Sensitive" mean in Java? D) Inheritance
A) Capitalization does not matter Answer: C
B) Identifiers like age and Age are different 27. "Abstraction" focuses on:
C) All code must be in uppercase A) Hiding complex implementation details from the user
D) Only keywords are sensitive B) Grouping data into a capsule
Answer: B C) Repeating code multiple times
20. What is the default case in a switch statement used D) Mathematical calculations
for? Answer: A
A) To start the switch 28. In the banking example, Account is the class. What
B) To handle values that don't match any other case would mySavings be?
C) To handle boolean logic A) A method
D) It is mandatory for every switch B) An object (instance)
Answer: B C) A keyword
## Part 3: Object-Oriented Programming (OOP) Pillars D) A package
21. How many main pillars of OOP are there? Answer: B
A) 2 29. Which keyword is used to create a new object?
B) 3 A) create
C) 4 B) build
D) 5 C) new
Answer: C D) instance
22. In OOP, a "Class" is best described as a: Answer: C
A) Specific instance 30. Which of the following is an example of a method
B) Blueprint or template (behavior)?
C) Data type for numbers A) int balance;
D) Method B) String name;
Answer: B C) deposit();
23. What is an "Object"? D) class Bank;
A) A reserved keyword Answer: C
B) An instance of a class ## Part 4: Data Types & Operations
Generated and formatted by
T & M MULTIFUNCTIONAL BUSINESS VENTURE, LASUED MAIN CAMPUS.
31. Which data type is best for a single letter like 'K'? A) [Link]()
A) String B) [Link]()
B) char C) [Link]()
C) byte D) Print()
D) float Answer: B
Answer: B 40. How many bits are in a standard Java int?
32. What is the standard type for high-precision decimal A) 8
numbers? B) 16
A) int C) 32
B) double D) 64
C) long Answer: C
D) short ## Part 5: Problem Solving & Advanced OOP
Answer: B 41. What is an "Algorithm"?
33. The ++ operator is known as the: A) A Java keyword
A) Decrement operator B) Step-by-step instructions to solve a problem
B) Addition operator C) A physical part of the computer
C) Increment operator D) An error in the code
D) Logical operator Answer: B
Answer: C 42. The first step in problem-solving is to:
34. What is the result of (int) 7.9? A) Write the code
A) 8 B) Understand the problem
B) 7.9 C) Test the software
C) 7 D) Draw a flowchart
D) Error Answer: B
Answer: C 43. Which diagram represents the logical flow of a
35. Which type holds only true or false? program?
A) bit A) Pie Chart
B) boolean B) Flowchart
C) logic C) Class Diagram
D) int D) Blueprint
Answer: B Answer: B
36. What does [Link]("A" + 1); output? 44. In a flowchart, a diamond shape usually represents:
A) B A) Start/Stop
B) A1 B) Input/Output
C) 66 C) A Decision (if-condition)
D) Error D) A Process
Answer: B Answer: C
37. The symbol { } in Java is used to: 45. What keyword is used to bring in the Scanner class?
A) Start a comment A) include
B) Group a block of code B) package
C) Separate variables C) import
D) Perform division D) using
Answer: B Answer: C
38. Which of these is NOT an arithmetic operator? 46. A Java file must be saved with which extension?
A) + A) .class
B) % B) .exe
C) && C) .java
D) D) .txt
Answer: C Answer: C
39. What is the syntax to print text without a new line? 47. What is the output of 5 + 2 3?
Generated and formatted by
T & M MULTIFUNCTIONAL BUSINESS VENTURE, LASUED MAIN CAMPUS.
A) 21 Answer: A
B) 11 55. If int x = 5;, what is the value of x after x++;?
C) 10 A) 5
D) 15 B) 4
Answer: B C) 6
48. Which operator is used for Logical OR? D) 10
A) && Answer: C
B) || 56. Which operator is used to add 2 to a variable x using a
C) ! shortcut?
D) |& A) x == 2
Answer: B B) x += 2
49. Every Java application must have at least one: C) x ++ 2
A) Loop D) x =+ 2
B) Scanner Answer: B
C) Class 57. In a flowchart, which shape is used for "Input/Output"
D) If-statement operations?
Answer: C A) Rectangle
50. If int x = 10;, what does x += 5; do? B) Parallelogram
A) Sets x to 5 C) Diamond
B) Adds 5 to x (x becomes 15) D) Oval
C) Checks if x equals 5 Answer: B
D) Multiplies x by 5 58. What is the correct syntax for a for loop header?
Answer: B A) for (i = 1 to 5)
## Part 6: Control Flow & Logic (Advanced) B) for (int i = 0; i < 5; i++)
51. Which statement is used to skip the current iteration C) for (int i : 5)
of a loop and move to the next one? D) for (while i < 5)
A) break Answer: B
B) return 59. Which logical operator represents "NOT"?
C) continue A) &&
D) exit B) ||
Answer: C C) !
52. In a switch statement, what happens if a break is D) !=
missing after a case? Answer: C
A) The program crashes 60. The if-else if-else structure is commonly called an:
B) The next case is executed (fall-through) A) If-Else Ladder
C) The switch restarts B) If-Else Circle
D) It skips to the default case C) Switch-Case
Answer: B D) Loop
53. Which loop is guaranteed to execute its block of code Answer: A
at least once? ## Part 7: Arrays & Methods
A) for loop 61. What is an Array?
B) while loop A) A method that returns a value
C) do-while loop B) A data structure that stores multiple values of the
D) nested loop same type
Answer: C C) A type of loop
54. What is the result of 10 % 5 == 0? D) A single variable that stores only one number
A) true Answer: B
B) false 62. What is the index of the first element in a Java array?
C) 0 A) 1
D) 2 B) -1
Generated and formatted by
T & M MULTIFUNCTIONAL BUSINESS VENTURE, LASUED MAIN CAMPUS.
C) 0 A) To make the code run faster
D) null B) To avoid code repetition and improve organization
Answer: C C) To create new data types
63. How do you declare an array of integers named D) To define variables
numbers? Answer: B
A) int numbers; ## Part 8: OOP Pillars - Inheritance & Polymorphism
B) int[] numbers; 71. Which keyword is used to achieve Inheritance in Java?
C) Array numbers; A) implements
D) numbers[] int; B) extends
Answer: B C) inherits
64. To get the number of elements in an array arr, you D) super
use: Answer: B
A) [Link]() 72. In inheritance, the class that is inherited from is called
B) [Link] the:
C) [Link] A) Child class
D) [Link] B) Subclass
Answer: B C) Parent class (or Superclass)
65. What is a "Method" in Java? D) Derived class
A) A way to store data Answer: C
B) A reusable block of code that performs a task 73. What is the main benefit of Inheritance?
C) A specific type of variable A) Data hiding
D) A class blueprint B) Code reuse
Answer: B C) Faster compilation
66. What does the return keyword do in a method? D) Memory reduction
A) Stops the program Answer: B
B) Sends a value back to where the method was called 74. "Method Overloading" is an example of which type of
C) Restarts the loop polymorphism?
D) Prints text to the console A) Runtime Polymorphism
Answer: B B) Compile-Time Polymorphism
67. Which part of a method defines the inputs it can C) Inheritance
receive? D) Encapsulation
A) Method name Answer: B
B) Return type 75. What defines Method Overloading?
C) Parameters A) Same method name, same parameters
D) Method body B) Different method names, same parameters
Answer: C C) Same method name, different parameters
68. If a method is defined as public static int add(int a, int D) Methods in different classes
b), what is its return type? Answer: C
A) void 76. "Method Overriding" occurs when:
B) static A) A subclass provides a specific implementation of a
C) int method already defined in its parent class
D) add B) Two methods have the same name in the same class
Answer: C C) A method calls itself
69. Which of the following is a valid array initialization? D) A class has multiple constructors
A) int[] n = {1, 2, 3}; Answer: A
B) int n = [1, 2, 3]; 77. Which term describes the ability of an object to take
C) int[] n = (1, 2, 3); on many forms?
D) int n = {1, 2, 3}; A) Encapsulation
Answer: A B) Abstraction
70. What is the purpose of using methods? C) Polymorphism
Generated and formatted by
T & M MULTIFUNCTIONAL BUSINESS VENTURE, LASUED MAIN CAMPUS.
D) Inheritance 85. Which keyword is used to define a class that cannot be
Answer: C instantiated on its own?
78. If Dog extends Animal, and both have a sound() A) final
method, which one runs when you call [Link]()? B) static
A) The Animal version C) abstract
B) The Dog version D) private
C) Both run Answer: C
D) Neither runs 86. An "Abstract Method" is a method that:
Answer: B A) Has no body (no implementation)
79. Can a Java class extend more than one parent class B) Is always private
directly? C) Is used to print data
A) Yes D) Cannot be overridden
B) No Answer: A
C) Only if they are abstract 87. In the Real-Life Example of an ATM, what represents
D) Only if they are in the same package Abstraction?
Answer: B A) The money inside
80. What is a "Constructor"? B) The user interface (buttons/screen) while hiding the
A) A method that destroys an object internal mechanical process
B) A special method used to initialize objects C) The plastic casing
C) A keyword for inheritance D) The bank staff
D) A type of loop Answer: B
Answer: B 88. Which pillar of OOP helps in reducing programming
## Part 9: OOP Pillars - Encapsulation & Abstraction complexity?
81. What is Encapsulation often called? A) Inheritance
A) Code Reuse B) Abstraction
B) Data Protection (or Data Hiding) C) Loops
C) Multiple Forms D) Variables
D) Blueprinting Answer: B
Answer: B 89. What is a "Getter" method?
82. Which access modifier is used to hide data within a A) A method used to update a private variable
class? B) A method used to retrieve the value of a private
A) public variable
B) protected C) A method used to delete an object
C) private D) A constructor
D) static Answer: B
Answer: C 90. A class that implements an abstract class MUST:
83. How do you access private data in an encapsulated A) Also be abstract
class? B) Provide implementations for all abstract methods
A) By using the new keyword C) Have the same name
B) Through public "Getter" and "Setter" methods D) Be private
C) It cannot be accessed at all Answer: B
D) By inheriting the class ## Part 10: Practical Applications & Synthesis
Answer: B 91. In a "Student Management System," what would score
84. What is the main benefit of Abstraction? be?
A) It allows code to be copied easily A) A Method
B) It hides complex implementation details and shows B) An Object
only essential features C) A Property (Attribute)
C) It makes the code longer D) A Class
D) it prevents the use of objects Answer: C
Answer: B
Generated and formatted by
T & M MULTIFUNCTIONAL BUSINESS VENTURE, LASUED MAIN CAMPUS.
92. Which of the following is a "Behavior" (Method) of a A) Polymorphism
Car class? B) Inheritance
A) String color; C) Encapsulation
B) int speed; D) Abstraction
C) drive(); Answer: C
D) Car myCar; 100. The phrase "One method name, many forms" best
Answer: C describes:
93. What does [Link](5 > 3 && 8 < 10); A) Variables
output? B) Abstraction
A) true C) Polymorphism
B) false D) Arrays
C) 5 Answer: C
D) Error ## Part 11: Methods & Functional Logic
Answer: A 101. In the method signature public static double
94. Which shape is used to represent the "Start" or "End" calculateInterest(double balance), what is the parameter?
of a flowchart? A) public
A) Rectangle B) calculateInterest
B) Oval C) balance
C) Diamond D) double
D) Triangle Answer: C
Answer: B 102. Which keyword is used to send a result back to the
95. If a class SavingsAccount extends Account, caller of a method?
SavingsAccount is the: A) give
A) Superclass B) return
B) Subclass C) output
C) Interface D) send
D) Object Answer: B
Answer: B 103. If a method does NOT return any value, its return
96. In Java, every class you create implicitly inherits from type must be:
which class? A) null
A) Main B) zero
B) System C) void
C) Object D) empty
D) String Answer: C
Answer: C 104. What is "Method Signature"?
97. What is the result of double x = 10 / 4; (using integer A) The body of the method
division)? B) The method name and its parameter list
A) 2.5 C) The comment above the method
B) 2.0 D) The file name
C) 3.0 Answer: B
D) 2 105. What happens when you call a method that has a
Answer: B return type but you don't assign it to a variable?
98. Which keyword is used to refer to the current object? A) The program crashes
A) this B) The value is returned but ignored
B) super C) The compiler gives an error
C) current D) The method doesn't execute
D) self Answer: B
Answer: A 106. Which of these correctly calls a method named
99. Which pillar of OOP is most concerned with display()?
"Security"? A) call display;
Generated and formatted by
T & M MULTIFUNCTIONAL BUSINESS VENTURE, LASUED MAIN CAMPUS.
B) display[]; Answer: B
C) display(); 114. What is the goal of "Abstraction"?
D) run display(); A) To show all internal code to the user
Answer: C B) To hide unnecessary details and show only essential
107. Can a method have more than one parameter? features
A) No, only one is allowed C) To create multiple copies of an object
B) Yes, they are separated by commas D) To link two unrelated classes
C) Only if they are the same data type Answer: B
D) Only if the method is static 115. Which of these is a real-world example of Abstraction
Answer: B mentioned in your notes?
108. In the expression int result = add(5, 3);, what are 5 A) A printed book
and 3 called? B) An ATM machine
A) Variables C) A calculator battery
B) Arguments D) A computer mouse
C) Operators Answer: B
D) References 116. A class that contains at least one abstract method
Answer: B must be declared as:
109. Why do we use "reusable blocks of code" (Methods)? A) private
A) To increase the file size B) static
B) To avoid writing the same code multiple times C) abstract
C) To make variables private D) final
D) To bypass the JVM Answer: C
Answer: B 117. What is "Method Overriding"?
110. A method defined inside a class is often called a: A) Creating a method with the same name in the same
A) Function class
B) Procedure B) Redefining a parent class method in a subclass to
C) Behavior (or Member Function) change its behavior
D) Logic Block C) Calling a method multiple times
Answer: C D) Using a method as a variable
## Part 12: Detailed OOP Implementation Answer: B
111. Which keyword is used to inherit from a class? 118. Which OOP pillar deals with "Bundling data and
A) implements methods together"?
B) extends A) Inheritance
C) using B) Polymorphism
D) provides C) Encapsulation
Answer: B D) Abstraction
112. In the relationship class Dog extends Animal, which is Answer: C
the Superclass? 119. If you have an abstract class Shape with a method
A) Dog draw(), can you do Shape s = new Shape();?
B) Animal A) Yes
C) Both B) No
D) Neither C) Only if the method is not empty
Answer: B D) Only in the main method
113. What is the primary purpose of the private access Answer: B
modifier? 120. What is the "Key Idea" of Polymorphism according to
A) To make the code run faster your summary table?
B) To restrict access to the variable from outside the A) Code reuse
class B) One method, many forms
C) To allow other classes to change the data C) Hide data
D) To make the variable a constant D) Hide complexity
Generated and formatted by
T & M MULTIFUNCTIONAL BUSINESS VENTURE, LASUED MAIN CAMPUS.
Answer: B A) At the beginning
## Part 13: Advanced Control Flow & Arrays B) In the middle
121. Which loop is best used when the number of C) At the end
repetitions is known? D) It isn't checked
A) while loop Answer: C
B) do-while loop 129. What is the correct way to initialize an array with
C) for loop values 10, 20, and 30?
D) if-else ladder A) int[] arr = {10, 20, 30};
Answer: C B) int arr = [10, 20, 30];
122. What does the continue statement do? C) int[] arr = (10, 20, 30);
A) Exits the entire loop D) Array arr = {10, 20, 30};
B) Skips the current iteration and moves to the next Answer: A
C) Stops the program 130. What is the value of i after the loop for(int i=0; i<3;
D) Repeats the same iteration i++) finishes?
Answer: B A) 2
123. What is the output of a loop for(int i=1; i<=5; i++) if it B) 3
contains if(i==3) break;? C) 4
A) 1 2 3 D) 0
B) 1 2 Answer: B
C) 1 2 4 5 ## Part 14: Logic & Operators
D) 3 4 5 131. Which operator is used for "Logical AND"?
Answer: B A) ||
124. How do you access the second element in an array B) &&
named scores? C) !
A) scores[2] D) &|
B) scores[1] Answer: B
C) [Link](2) 132. What does the expression !(5 > 3) evaluate to?
D) scores{1} A) true
Answer: B B) false
125. What happens if you try to access arr[10] in an array C) 5
of size 5? D) Error
A) It returns 0 Answer: B
B) It returns null 133. The += operator (e.g., x += 5) is called an:
C) An "ArrayIndexOutOfBoundsException" error occurs A) Arithmetic operator
D) It creates more space automatically B) Assignment operator
Answer: C C) Relational operator
126. Which of these is a correct way to update an array D) Logical operator
element? Answer: B
A) numbers[0] = 10; 134. In the Student Grading System example, which
B) numbers{0} = 10; structure is used to assign grades?
C) numbers = 10; A) while loop
D) update(numbers, 0, 10); B) if-else ladder
Answer: A C) switch statement
127. A switch statement is an alternative to: D) array
A) A for loop Answer: B
B) Multiple if-else if statements 135. Which operator checks if two values are NOT equal?
C) A method call A) ==
D) A class definition B) !!
Answer: B C) !=
128. In a do-while loop, where is the condition checked? D) <>
Generated and formatted by
T & M MULTIFUNCTIONAL BUSINESS VENTURE, LASUED MAIN CAMPUS.
Answer: C A) build
136. What is the output of [Link](10 / 2 + 3);? B) create
A) 2 C) new
B) 8 D) make
C) 5 Answer: C
D) 13 144. What is the starting point of every Java application?
Answer: B A) The constructor
137. What is pseudo-code? B) The first line of the file
A) Actual Java code C) The main method
B) An informal way of writing program steps in English D) The [Link] statement
C) A type of error Answer: C
D) A database language 145. In the "Car" analogy, "Color" and "Speed" are:
Answer: B A) Methods
138. In an if statement, the code inside the { } block runs B) Actions
only if the condition is: C) Properties (Attributes)
A) False D) Constructors
B) True Answer: C
C) Positive 146. In the "Car" analogy, "Move" and "Stop" are:
D) Zero A) Properties
Answer: B B) Methods (Actions)
139. What does x = x - 1 mean using the decrement C) Classes
operator? D) Objects
A) x-- Answer: B
B) x-1 147. What does "WORA" stand for in Java?
C) x -= A) Work On Right Application
D) --x B) Write Once, Run Anywhere
Answer: A C) Windows Only Run App
140. Which data type is used to store decimal values like D) With Object-Oriented Reliable Access
99.99? Answer: B
A) int 148. Which tool converts Java source code into bytecode?
B) double A) JVM
C) char B) Compiler
D) String C) Scanner
Answer: B D) Editor
## Part 15: General Review & Best Practices Answer: B
141. What is the result of [Link]("Result: " + 5 149. In a flowchart, what does a rectangle represent?
+ 5);? A) Decision
A) Result: 10 B) Start/End
B) Result: 55 C) Process/Action
C) Result: 5 D) Input/Output
D) Error Answer: C
Answer: B 150. What is the most important rule when naming a Java
142. Why do we use comments in Java? class?
A) To tell the JVM what to do A) It must start with a number
B) To make the code easier for humans to understand B) It must be in all lowercase
C) To hide errors C) The file name must match the class name
D) To increase speed D) It cannot have more than 5 letters
Answer: B Answer: C
143. Which of these is a keyword used to create an ## Part 16: Decision Making & Logic
instance of a class?
Generated and formatted by
T & M MULTIFUNCTIONAL BUSINESS VENTURE, LASUED MAIN CAMPUS.
151. In an if-else if-else ladder, what happens if the first if ## Part 17: Objects & Classes in Depth
condition is true? 158. Which of these best defines a "Class" in Java?
A) All subsequent else if blocks are also checked A) A real-world entity like a specific car
B) Only the else block is executed B) A blueprint or template used to create objects
C) The first block executes and the rest of the ladder is C) A method that prints data
skipped D) A variable that stores text
D) The program restarts Answer: B
Answer: C 159. In the code Student s1 = new Student();, what is s1?
152. What is the correct syntax for an "Else If" statement A) A class
in Java? B) An object (instance)
A) elseif (condition) C) A constructor
B) else if (condition) D) A package
C) if else (condition) Answer: B
D) else (condition) 160. What are "Properties" in a class also known as?
Answer: B A) Methods
153. Based on your notes, if a student's score is 75, which B) Behaviors
grade would be printed by the provided ladder? C) Attributes or Fields
A) Excellent D) Parameters
B) Pass Answer: C
C) Fail 161. In your Student class example, name and score are
D) Invalid examples of:
Answer: B A) Methods
154. The else block in a decision structure is: B) Objects
A) Mandatory for every if C) Properties
B) Used to handle cases where no previous conditions D) Keywords
were met Answer: C
C) Used to start a new loop 162. What does the code [Link] = "Ada"; accomplish?
D) Only for numerical comparisons A) It creates a new class called Ada
Answer: B B) It assigns the value "Ada" to the name property of
155. In the expression if (number > 0), the part inside the object s1
parentheses is known as a: C) It deletes the student record
A) Variable D) It prints "Ada" to the console
B) Boolean expression Answer: B
C) Method call 163. To execute a behavior of an object, such as
D) String literal [Link]();, we use:
Answer: B A) Dot notation
156. What is the result of a relational operation like x >= B) Plus notation
50? C) Parentheses only
A) An integer D) Brackets
B) A boolean (true or false) Answer: A
C) A string 164. According to your notes, Object-Oriented
D) A double Programming (OOP) helps organize code into:
Answer: B A) One large block
157. If int score = 40;, which block will execute in a ladder B) Smaller, reusable parts
where score >= 80 is "Excellent" and score >= 50 is "Pass"? C) Only mathematical formulas
A) The Excellent block D) Global variables
B) The Pass block Answer: B
C) The final else block (Fail) 165. In the "Car" analogy, if Car is the class, which of these
D) None of them is an Object?
Answer: C A) Color
Generated and formatted by
T & M MULTIFUNCTIONAL BUSINESS VENTURE, LASUED MAIN CAMPUS.
B) Speed
C) A specific Toyota Camry in your driveway
D) The drive() method
Answer: C
166. What is the purpose of the void display() method in
the Student Management System?
A) To calculate the student's age
B) To show the student's data (name and score)
C) To create a new student
D) To close the program
Answer: B
167. How many objects can you create from a single class?
A) Only one
B) Exactly two
C) As many as needed
D) None
Answer: C
168. Which keyword is essential for creating a new
instance of a class?
A) static
B) void
C) new
D) class
Answer: C
169. In the provided example, why does [Link]() print
different data than [Link]()?
A) Because they use different methods
B) Because each object has its own unique set of
property values
C) Because they are in different files
D) Because the code is wrong
Answer: B
170. What is the relationship between a Class and an
Object?
A) They are the exact same thing
B) An Object is an instance of a Class
C) A Class is an instance of an Object
D) They have no relationship
Answer: B
Generated and formatted by
T & M MULTIFUNCTIONAL BUSINESS VENTURE, LASUED MAIN CAMPUS.