CS203 – Object Oriented Programming

Exam 1 Practice Test • Professor Mahmut Unan • UAB CS

40 Questions • True/False & Multiple Choice • Covers Weeks 1–6 • Easy / Foundational Level
Grounded in lecture review slides (CS203_week06REVIEW) and lab exercises
Section 1: OOP Fundamentals & Why OOP
Topics from Week 01 review slides — What is OOP, benefits of OOP
Question 1 — True / False
Object-oriented programming (OOP) allows programmers to define not only the data type of a data structure, but also the types of operations (functions) that can be applied to the data structure.
Question 2 — Multiple Choice
Which of the following is NOT a benefit of OOP as discussed in the review?
Question 3 — True / False
The idea of OOP is to implement real-world entities like inheritance, hiding, and polymorphism in programming.
Question 4 — Multiple Choice
According to the lecture, the purpose of OOP is to bind together:
Section 2: Java Basics & Java vs Python
Compilation, JVM, types, syntax differences — from Week 01 review
Question 5 — True / False
Java is an interpreted language, while Python is a compiled language.
Question 6 — Multiple Choice
What does JVM stand for?
Question 7 — Multiple Choice
In Java, how do you signify blocks of code?
Question 8 — True / False
In Java, a semicolon ; signals the end of a statement. Your program will fail to compile if a statement does not end with a semicolon.
Question 9 — Multiple Choice
Java is described as a strongly and explicitly typed language. What does this mean?
Question 10 — Multiple Choice
The output from the Java compiler is called:
Question 11 — Multiple Choice
Which of the following is NOT a primitive type in Java?
Question 12 — Multiple Choice
In Java, && represents the logical ______ operator, and || represents the logical ______ operator.
Question 13 — Multiple Choice
Java was originally developed by James Gosling at:
Question 14 — True / False
In Java, all functions (methods) must declare their return type.
Section 3: Classes & Objects
State, functionality, classes as blueprints — from Weeks 02–03 review
Question 15 — Multiple Choice
A class is best described as:
Question 16 — Multiple Choice
Given the analogy from the lecture: "Dog" is the class, "Scooby Doo" is the ______.
Question 17 — Multiple Choice
In the lecture's Dog example, which of the following would be considered state (data) of the Dog object?
Question 18 — True / False
Everything in Java is an Object, including primitive types like int and boolean.
Question 19 — Multiple Choice
Consider the following code from a Vehicle class. What is the return type of a constructor?
public class Vehicle { public Vehicle(int numWheels, int numDoors, String name) { // set member variables } }
Question 20 — Multiple Choice
Looking at this code from the Book class used in Lab 3, what does the constructor do?
public Book(String n, int p, boolean s) { name = n; page = p; stock = s; }
Section 4: Encapsulation & Access Modifiers
public, private, protected — hiding implementation details — Weeks 03–05 review
Question 21 — Multiple Choice
Encapsulation is best described as:
Question 22 — Multiple Choice
Which access modifier makes a member accessible only within the class it is declared in?
Question 23 — True / False
According to the lecture, 99.99% of the time your member variables should be private.
Question 24 — Multiple Choice
The protected access modifier allows access from:
Question 25 — Multiple Choice
In the Calculator class from Lab 6, what are get_first_number() and get_second_number() examples of?
public int get_first_number() { return num1; } public int get_second_number() { return num2; }
Question 26 — Multiple Choice
An accessor method does what?
Question 27 — True / False
According to the rule of thumb from lecture, you should design methods that are either accessors or mutators, but not both.
Section 5: Inheritance & Class Hierarchy
extends, super(), overriding, Object as root — Weeks 03–05 review
Question 28 — Multiple Choice
In the Lab 4 code below, what does extends mean?
public class BossCharacter extends GameCharacter { // ... }
Question 29 — Multiple Choice
In the Lab 6 ScientificCalculator, what does super(a, b) do?
public ScientificCalculator(int a, int b) { super(a, b); // Call the constructor of the parent class }
Question 30 — True / False
According to the review, Object is the root of the class hierarchy in Java — all classes are subclasses of Object.
Question 31 — Multiple Choice
Which of the following is NOT inherited by a subclass?
Question 32 — Multiple Choice
In the Lab 4 BossCharacter, the @Override annotation on attack() means:
@Override public int attack() { return super.attack() + 20; }
Question 33 — Multiple Choice
From the review's Vehicle hierarchy, which is a correct class relationship?
Vehicle / \ Car Truck / | \ Hatchback Coupe Sedan
Section 6: Object References & toString()
References, mutation, toString(), equals() — from review slides
Question 34 — Multiple Choice
Consider this code from the review slides:
Greeter worldGreeter = new Greeter("World"); Greeter anotherGreeter = worldGreeter; anotherGreeter.setName("Dave");
What does worldGreeter.sayHello() return?
Question 35 — True / False
Because every object is of type Object, every object has a toString() method.
Question 36 — Multiple Choice
If you do not override toString(), the default implementation returns:
Section 7: Static Variables, Local vs Instance Variables & Design
Static members, variable scope, class design patterns — Weeks 04–06 review
Question 37 — True / False
A static variable belongs to individual objects of a class, not the class itself.
Question 38 — Multiple Choice
When should you use an instance variable instead of a local variable?
Question 39 — True / False
String is an immutable class in Java — no method in String can modify the contents of the string.
Question 40 — Multiple Choice
According to the review, when identifying what should be a class (Abbot's method), you should look for:

Your Results