CS203 Test 1 Review

135 Practice Questions covering Objects, Classes, Encapsulation, Scope, Graphics, and Static Modifiers.

Part 1: Fundamental Concepts (1-15)

Easy
1.
Explain the relationship between a Class and an Object using a real-world analogy (like a blueprint or a recipe).
Show Answer
A Class is the blueprint or template (e.g., the recipe for pancakes). The Object is the actual instance created from that blueprint (e.g., the actual pancake you eat).
Easy
2.
In Java, if we have a class named Dog, write the line of code required to create a new instance of Dog and assign it to a variable named myPuppy.
Show Answer
Dog myPuppy = new Dog();
Harder than Easy
3.
Identify whether the following are examples of State or Functionality for a Car object: drive(), fuelLevel, color, honkHorn().
Show Answer
  • drive(): Functionality
  • fuelLevel: State
  • color: State
  • honkHorn(): Functionality
Intermediate
4.
Look at the code below. Explain what the keyword this refers to in the whine method.
public class Dog {
    private String name;

    public void whine() {
        System.out.println(this.name + " whines!");
    }
}
Show Answer
It refers to the current object instance that is calling the method. It allows the code to differentiate between the instance variable name and any local variables that might have the same name.
Easy
5.
Which access modifier should you strictly use for instance variables (fields) to ensure good encapsulation?
A) public
B) private
C) protected
Show Answer
B) private
Harder than Easy
6.
If a member variable is marked private, how can an external object (like Main) read or modify its value? What types of methods do you need to write?
Show Answer
You need Getter (accessor) and Setter (mutator) methods.
Intermediate
7.
Write a simple Java class named Account.
  • It should have one private integer variable: balance.
  • It should have a public method getBalance() that returns the balance.
  • It should have a public method deposit(int amount) that adds to the balance.
Show Answer
public class Account {
    private int balance;

    public int getBalance() {
        return this.balance;
    }

    public void deposit(int amount) {
        this.balance += amount;
    }
}
Easy
8.
True or False: Local variables (declared inside a method) are automatically initialized to default values (like 0 or null) by Java.
Show Answer
False. Local variables must be initialized manually. Instance variables are automatically initialized (0, null, etc.).
Harder than Easy
9.
Explain the difference in lifetime (how long they exist) between an Instance Variable and a Local Variable.
Show Answer
Instance variables exist as long as the object exists. Local variables only exist while the method they are in is executing; they are destroyed once the method finishes.
Intermediate
10.
In the following code, identify the scope error. Why will this code fail to compile?
public void calculate() {
    int x = 10;
    if (x > 5) {
        int y = 20;
    }
    System.out.println(x + y); 
}
Show Answer
The variable y is declared inside the if block. It ceases to exist outside that block, so System.out.println(x + y) cannot find y.
Easy
11.
To create a custom drawing in a Java GUI application, you typically extend JComponent and override which method?
A) draw()
B) paintComponent(Graphics g)
C) makeVisible()
Show Answer
B) paintComponent(Graphics g)
Harder than Easy
12.
When setting up a JFrame, what method must be called at the end to actually make the window appear on the screen?
Show Answer
frame.setVisible(true);
Easy
13.
If a variable is declared as static, how many copies of that variable exist if you create 100 objects of that class?
Show Answer
Only one copy exists, shared by all 100 objects.
Harder than Easy
14.
Why is the main method in Java always declared as static?
Show Answer
It must be static so the Java Virtual Machine (JVM) can call it without needing to instantiate an object of the class first.
Intermediate
15.
Analyze the output of the following code. What will be printed?
public class Counter {
    public static int count = 0;

    public Counter() {
        count++;
    }

    public static void main(String[] args) {
        Counter c1 = new Counter();
        Counter c2 = new Counter();
        Counter c3 = new Counter();
        System.out.println(Counter.count);
    }
}
Show Answer
3. (Since count is static, it is shared. Every time new Counter() is called, the constructor increments the shared variable).

Part 2: General OOP & Objects (16-55)

Easy
16.
True or False: A class is an actual object that exists in computer memory when the program runs.
Show Answer
False. A Class is just the blueprint/code. The Object is what exists in memory during runtime.
Easy
17.
If you have a class Car, and you write Car c1 = new Car(); and Car c2 = c1;, how many distinct Car objects exist in memory?
Show Answer
One. c2 = c1 simply copies the reference (address), pointing both variables to the single object in memory.
Harder than Easy
18.
Explain the difference between a primitive type (like int) and an object type (like String or Dog) regarding what is stored in the variable.
Show Answer
A primitive variable stores the actual value (e.g., 5). An object variable stores the memory address (reference) pointing to where the object is.
Intermediate
19.
Write the code to create a class named Lamp that has one instance variable isOn (boolean). Include a constructor that sets isOn to false initially.
Show Answer
public class Lamp {
   boolean isOn;
   public Lamp() {
       this.isOn = false;
   }
}
Easy
20.
In the statement Greeter worldGreeter = new Greeter("World");, what is worldGreeter technically called?
A) The Object
B) The Class
C) The Object Reference
D) The Constructor
Show Answer
C) The Object Reference.
Intermediate
21.
If you try to call a method on a variable whose value is null (e.g., dog.bark() where dog is null), what specific error (exception) occurs at runtime?
Show Answer
NullPointerException
Easy
22.
What keyword is used to create a new instance of a class?
Show Answer
new
Harder than Easy
23.
Why do we say an object "contains multitudes" or "has state"? What specifically constitutes the "state" of an object in Java code?
Show Answer
State refers to the values stored in the object's instance variables (fields) at any given moment.
Easy
24.
Match the following concepts to their Java implementation:
Action/Behavior -> _________ (Variables or Methods?)
Data/Attribute -> _________ (Variables or Methods?)
Show Answer
Behavior -> Methods; Data -> Variables.
Intermediate
25.
Given the method signature public int add(int a, int b), what does the keyword int before the method name signify?
Show Answer
Return Type. It signifies the method will return an integer value.
Harder than Easy
26.
If a method returns void, can you still use the return keyword inside it? If so, how?
Show Answer
Yes. You can use return; (with no value) to exit the method early.
Easy
27.
What is the name of the special method that is called automatically when an object is created?
Show Answer
Constructor.
Intermediate
28.
Write a method named isAdult for a Person class. It should take no parameters and return true if the person's age (an instance variable) is greater than or equal to 18, and false otherwise.
Show Answer
public boolean isAdult() {
    if (this.age >= 18) { return true; }
    else { return false; }
}
Easy
29.
True or False: A constructor must have the exact same name as the class.
Show Answer
True.
Harder than Easy
30.
What is "Method Overloading"?
A) Writing a method that is too long.
B) Having multiple methods with the same name but different parameter lists.
C) Having a method call itself.
Show Answer
B) Same name, different parameters.
Intermediate
31.
In a method public void setName(String name), how do you assign the parameter name to the instance variable name without naming conflict?
Show Answer
this.name = name;
Easy
32.
Which access modifier allows a variable/method to be accessed by any other class in the project?
Show Answer
public
Easy
33.
Which access modifier restricts access only to the class it is defined in?
Show Answer
private
Harder than Easy
34.
Why is it considered bad practice to make all your instance variables public?
Show Answer
It breaks Encapsulation. It allows external code to change data to invalid states (e.g., setting age to -5) without the class knowing.
Intermediate
35.
If numWheels is a private variable in the Car class, write a standard "Setter" method signature and body to update it.
Show Answer
public void setNumWheels(int num) {
    this.numWheels = num;
}
Easy
36.
What does "API" stand for in the context of your class design (public methods)?
A) Automated Private Interface
B) Application Programming Interface
C) Access Protected Integer
Show Answer
B) Application Programming Interface.
Harder than Easy
37.
If a method is marked protected, who can access it? (Name two groups).
Show Answer
The class itself, classes in the same package, and Subclasses.
Intermediate
38.
You have a private variable password. You want to allow external code to change it, but only if the new password is longer than 5 characters. Write a setter method that enforces this logic.
Show Answer
public void setPassword(String p) {
    if (p.length() > 5) {
        this.password = p;
    }
}
Easy
39.
True or False: It is impossible to read a private variable from another class. (Hint: Think about getters).
Show Answer
False. You can read it indirectly if the class provides a public "Getter" method.
Easy
40.
If you declare int score; as an instance variable, what is its initial value?
Show Answer
0 (Zero).
Easy
41.
If you declare int score; inside a method (local variable) and try to print it immediately, what happens?
Show Answer
Compiler Error. Local variables have no default value and must be initialized before use.
Harder than Easy
42.
What is "Shadowing"?
A) When a local variable has the same name as an instance variable.
B) When a class has no public methods.
C) When an object is set to null.
Show Answer
A) When a local variable has the same name as an instance variable.
Intermediate
43.
Look at this code. Which x is printed?
public class Test {
    int x = 5;
    public void print() {
        int x = 10;
        System.out.println(x);
    }
}
Show Answer
10. The local variable x shadows the instance variable x.
Intermediate
44.
How long does a Local Variable live in memory?
Show Answer
It exists only while the method (or block) it is declared in is executing.
Easy
45.
What is the default value for an object reference (e.g., String s;) if it is an instance variable?
Show Answer
null
Harder than Easy
46.
Can you use an access modifier (like public or private) on a local variable inside a method?
Show Answer
No. Access modifiers are for class members, not local variables.
Intermediate
47.
Refactor this code to fix the scope error:
public void check() {
    if (true) {
        String message = "Hello";
    }
    System.out.println(message); // Error here
}
Show Answer
public void check() {
    String message = ""; // Initialize here
    if (true) {
        message = "Hello";
    }
    System.out.println(message);
}
Easy
48.
In Java Graphics coordinate systems, where is the point (0, 0) located?
A) Center of the screen
B) Bottom-Left
C) Top-Left
Show Answer
C) Top-Left.
Harder than Easy
49.
Why do we often cast the Graphics g object to Graphics2D g2 inside paintComponent?
Show Answer
Graphics2D is a newer, more powerful class that extends Graphics. Casting allows access to advanced drawing methods (like stroke width).
Intermediate
50.
Write a single line of code to draw a rectangle at x=10, y=10 with width=50 and height=100 using a Graphics object named g.
Show Answer
g.drawRect(10, 10, 50, 100);
Easy
51.
What keyword is used to declare a constant variable in Java?
Show Answer
final
Harder than Easy
52.
If you have a class MathUtils with a method public static int add(int a, int b), how do you call this method from Main?
A) new MathUtils().add(1, 2);
B) MathUtils.add(1, 2);
Show Answer
B) MathUtils.add(1, 2); (Called on the Class, not an object).
Intermediate
53.
Why are constants (like Math.PI or Color.RED) usually declared as static?
Show Answer
Efficiency. Since the value never changes (final) and is the same for everyone, we only need one copy in memory (static), not a copy for every single object.
Easy
54.
What is the naming convention for static final constants? (e.g., how would you write "max speed"?)
Show Answer
ALL_CAPS_WITH_UNDERSCORES (e.g., MAX_SPEED).
Harder than Easy
55.
If class Dog has a static variable dogCount, and you create 5 Dog objects, what happens if one object changes the value of dogCount?
Show Answer
It changes for all 5 objects because they all share that one single static variable.

Part 3: Java Basics & Class Structure (56-95)

Easy
56.
True or False: A Java class can have multiple methods with the same name, as long as their parameter lists are different.
Show Answer
True. (This is called Method Overloading).
Easy
57.
What are the 8 primitive types in Java? (Name at least 4).
Show Answer
int, double, boolean, char, byte, short, long, float.
Intermediate
58.
Write a constructor for a class named Book that takes two parameters (String title, int pages) and assigns them to the corresponding instance variables.
Show Answer
public Book(String title, int pages) {
    this.title = title;
    this.pages = pages;
}
Harder than Easy
59.
If you do not write any constructor in your class, what does Java provide for you automatically?
Show Answer
Default Constructor. (A no-argument constructor that does nothing).
Easy
60.
What is the standard naming convention for a class in Java? (e.g., dog, DOG, Dog, or dog_class)?
Show Answer
UpperCamelCase (e.g., Dog).
Intermediate
61.
Given String s1 = "Java"; and String s2 = "Java"; (created literally), does s1 == s2 usually return true or false? Why is comparing Strings with == dangerous?
Show Answer
True (usually), but dangerous. == compares memory addresses. Literal strings are often pooled (same address), but if one was created with new String(), == would fail. Always use .equals().
Easy
62.
Which keyword is used to import a library class (like Scanner or JFrame) so you don't have to type its full package name every time?
Show Answer
import
Harder than Easy
63.
Explain what "Garbage Collection" means in the context of Java objects.
Show Answer
The process where Java automatically frees up memory used by objects that are no longer referenced by any variable.
Easy
64.
If a method is defined as public String getName(), what type of data must the return statement provide?
Show Answer
String
Easy
65.
True or False: A method declared as void cannot have any parameters.
Show Answer
False. void means it returns nothing; it can still take parameters.
Intermediate
66.
You have a method public void drive(int miles). Inside this method, you want to decrease the fuel instance variable by 1 for every 10 miles driven. Write the line of code to do this calculation.
Show Answer
this.fuel -= (miles / 10);
Harder than Easy
67.
What is a "Side Effect" of a method? (Hint: Think about what happens to the state of an object).
Show Answer
A change in the state of the object (or the outside world, like printing) that persists after the method finishes.
Intermediate
68.
Write a method called reset() that sets two instance variables, score (int) to 0 and isActive (boolean) to false.
Show Answer
public void reset() {
    this.score = 0;
    this.isActive = false;
}
Easy
69.
Which of the following is a valid method signature?
A) public void (int x)
B) public void doSomething(int x)
C) void public doSomething(x)
Show Answer
B) public void doSomething(int x)
Harder than Easy
70.
Can a method return an Object (like a Dog or String) instead of a primitive?
Show Answer
Yes.
Intermediate
71.
Identify the error in this code:
public int getAge() {
    int age = 20;
    // Missing something here
}
Show Answer
Missing Return Statement. The method promises to return an int, but implies it finishes without returning one.
Easy
72.
In the "Black Box" analogy of Encapsulation, what represents the "interface" or buttons on the outside of the box?
A) Private Variables
B) Public Methods
C) Comments
Show Answer
B) Public Methods.
Easy
73.
True or False: You can have a private method in a class.
Show Answer
True.
Harder than Easy
74.
Why might a programmer choose to make a method private instead of public? (Hint: Helper methods).
Show Answer
Helper Methods: If a method is only used internally by other methods in the class and shouldn't be touched by the outside world.
Intermediate
75.
If you have a private boolean isOpen, write a "Getter" method for it. (Note: Boolean getters often follow a specific naming convention different from get...).
Show Answer
public boolean isOpen() { return this.isOpen; } (Convention for booleans is often isVar instead of getVar).
Easy
76.
Does protected access allow unrelated classes in a different package to access the member?
Show Answer
No.
Intermediate
77.
You are writing a Student class. You want to ensure the gpa variable can never be set below 0.0 or above 4.0. Write a setGpa(double val) method that only sets the value if it is valid.
Show Answer
public void setGpa(double val) {
    if(val >= 0.0 && val <= 4.0) {
        this.gpa = val;
    }
}
Harder than Easy
78.
If a variable is public, it implies a "contract" that the variable will always exist. Why does changing a public variable to private later cause problems for other code?
Show Answer
Breaking Dependencies: Other code might be directly accessing .name. If you make it private, all that external code breaks.
Easy
79.
Which principle of OOP focuses on "hiding the implementation details" and "showing only functionality"?
A) Inheritance
B) Abstraction/Encapsulation
C) Polymorphism
Show Answer
B) Abstraction/Encapsulation.
Easy
80.
Can two different methods in the same class both have a local variable named temp?
Show Answer
Yes. Scopes are independent.
Easy
81.
True or False: A parameter passed into a method (e.g., int x in void foo(int x)) acts like a Local Variable.
Show Answer
True.
Intermediate
82.
Look at the code below. Is line 4 valid? Why or why not?
1. public void test() {
2.    int a = 10;
3. }
4. int b = a; 
Show Answer
No. Variable a is local to test(). It does not exist at line 4.
Harder than Easy
83.
If you declare an instance variable int x and a local variable int x in a method, how do you specify that you want to use the instance variable inside that method?
Show Answer
this.x
Intermediate
84.
What is the "scope" of a variable defined inside a for loop (e.g., for(int i=0; i<10; i++))?
Show Answer
Loop Scope: It exists only inside the loop block.
Easy
85.
True or False: Instance variables are destroyed as soon as the method that created the object finishes.
Show Answer
False. Instance variables live as long as the object lives (until Garbage Collection).
Harder than Easy
86.
Explain why local variables must be initialized, whereas instance variables don't have to be.
Show Answer
Safety/Design: Java wants to ensure calculations are deterministic. Instance variables have logical "defaults" (0, null), but a local variable usually represents temporary calculation steps, so relying on a default there is often a logic bug.
Intermediate
87.
What is the value of count after this code runs?
int count = 0;
if (count < 5) {
    int temp = 5;
    count = temp + 2;
}
Show Answer
7.
Easy
88.
Which package contains the Color class (e.g., Color.RED)?
A) java.lang
B) java.awt
C) javax.swing
Show Answer
B) java.awt
Easy
89.
True or False: If you change the color using g.setColor(Color.BLUE), all shapes drawn previously will change to blue.
Show Answer
False. It acts like a pen; only future drawings are blue.
Intermediate
90.
Write a line of code using g.drawString to write "Hello" at position (50, 50).
Show Answer
g.drawString("Hello", 50, 50);
Harder than Easy
91.
Why can't a static method (like main) directly access a non-static instance variable (like name) without creating an object first?
Show Answer
Reason: Static methods belong to the class blueprint. Non-static variables belong to specific "houses" (objects). The blueprint doesn't know which house's name you are talking about.
Easy
92.
Which method in the Math class would you use to find the square root of a number?
Show Answer
Math.sqrt()
Intermediate
93.
If you have public static final int MAX_USERS = 10;, can you write MAX_USERS = 20; later in the code? Why?
Show Answer
No. It is final (constant).
Easy
94.
To use JFrame, you generally import javax.______.
Show Answer
swing (javax.swing).
Harder than Easy
95.
If count is a static variable, and you increment it in the constructor of a class, what does count essentially track?
Show Answer
Total Objects: It tracks the total number of objects of that class created so far.

Part 4: The Class Blueprint & Objects (96-135)

Easy
96.
True or False: An object is an "instance" of a class.
Show Answer
True.
Easy
97.
Which of the following is the correct syntax to define a class named Robot?
A) class Robot { }
B) public class Robot { }
C) def Robot:
Show Answer
B) public class Robot { }
Intermediate
98.
Write a constructor for a class Rectangle that accepts width and height. Inside the constructor, ensure that if the user passes a negative value, the dimension is set to 0 instead.
Show Answer
public Rectangle(int w, int h) {
    if (w < 0) w = 0;
    if (h < 0) h = 0;
    this.width = w;
    this.height = h;
}
Harder than Easy
99.
What is the difference between declaring a variable (Dog d;) and instantiating it (d = new Dog();)?
Show Answer
Declaration vs Instantiation: Declaration (Dog d) only creates a space for a reference (label). Instantiation (new Dog()) actually creates the object in memory.
Easy
100.
If you have a class Cat, can you create an array of Cat objects? (e.g., Cat[] cats = new Cat[5];).
Show Answer
Yes.
Intermediate
101.
If you create an array Cat[] cats = new Cat[5];, what is the value of cats[0] immediately after creation (before you put any actual Cats into it)?
Show Answer
null. (The array exists, but the slots are empty).
Easy
102.
What keyword represents the "current object" inside a method?
Show Answer
this
Harder than Easy
103.
Why do we usually put each public class in its own file named ClassName.java?
Show Answer
Organization/Java Requirement: Java compilers generally require public classes to be in files matching their name.
Easy
104.
In the method signature public double calculateTax(double price), what is the return type?
Show Answer
double
Easy
105.
True or False: A method can accept multiple parameters, but can only return one value.
Show Answer
True.
Intermediate
106.
You have a method public void speak(String text). You want to call another method log() inside it, passing the same text. Write the line of code to call log.
Show Answer
this.log(text); (or just log(text);).
Harder than Easy
107.
Explain what happens if you write a method that is supposed to return an int, but you put return "Hello"; inside it.
Show Answer
Compiler Error. Type mismatch.
Intermediate
108.
Write a method isEven that takes an integer n and returns true if it is even, and false otherwise. (Hint: Use the modulo operator %).
Show Answer
public boolean isEven(int n) {
    return (n % 2 == 0);
}
Easy
109.
What implies that a method is a "mutator" (setter)?
A) It returns a value.
B) It changes the state (instance variables) of the object.
C) It is static.
Show Answer
B.
Harder than Easy
110.
If you have two methods: void move(int x) and void move(int x, int y), what is this feature called?
Show Answer
Method Overloading.
Intermediate
111.
In the code below, identify the logic error. The goal is to prevent negative speeds.
public void setSpeed(int s) {
    this.speed = s;
    if (s < 0) {
        System.out.println("Error");
    }
}
Show Answer
Logic Error: The assignment this.speed = s; happens before the check. The invalid value is already set. The check should come first.
Easy
112.
Which access modifier is the most "secretive" or restrictive?
Show Answer
private
Easy
113.
True or False: A public method can access a private instance variable in the same class.
Show Answer
True.
Harder than Easy
114.
You are designing a BankAccount class. Why should the balance variable be private instead of public? Give one concrete scenario where public would be dangerous.
Show Answer
Safety: If public, someone could do myAccount.balance = -1000000;. Private ensures you can only change it via withdraw() which checks for funds.
Intermediate
115.
Write a Setter for a variable String name. The requirement is: the name cannot be null and cannot be an empty string "".
Show Answer
public void setName(String n) {
    if (n != null && !n.equals("")) {
        this.name = n;
    }
}
Easy
116.
Access modifiers control:
A) How fast the code runs.
B) Visibility (who can see/use the code).
C) How much memory is used.
Show Answer
B) Visibility.
Harder than Easy
117.
If a class Person has a private method updateAge(), can the Main class call p.updateAge()?
Show Answer
No. It is private.
Intermediate
118.
What is the standard naming convention for a "Getter" method for a boolean variable named isReady?
A) getIsReady()
B) getReady()
C) isReady()
Show Answer
C) isReady() (Standard Java convention for boolean getters).
Easy
119.
True or False: Encapsulation makes code harder to debug because variables are hidden. (Hint: Think about knowing where data is changed).
Show Answer
False. It makes debugging easier because you know exactly which methods are capable of modifying the variable.
Easy
120.
If you define int i inside a for loop header, can you access i after the loop finishes?
Show Answer
No. Scope is limited to the loop.
Easy
121.
Which type of variable gets a "default value" (like 0 or false) automatically?
A) Local Variable
B) Instance Variable
Show Answer
B) Instance Variable.
Intermediate
122.
Analyze this code. What will it print?
int x = 5;
public void mystery() {
    int x = 10;
    this.x = 20;
    System.out.println(x);
}
Show Answer
10. (It prints the local variable x).
Harder than Easy
123.
Why does Java strictly enforce that local variables must be initialized before use, causing a compile-time error if they aren't?
Show Answer
Reliability: Using "garbage" or uninitialized data causes unpredictable bugs. Java forces you to be explicit.
Intermediate
124.
You have an instance variable total. You want to write a method that adds a local variable amount to it. Write the line of code.
Show Answer
this.total += amount;
Easy
125.
True or False: A method parameter (e.g., x in f(int x)) is visible to other methods in the same class.
Show Answer
False.
Harder than Easy
126.
What is the "scope" of a parameter?
A) The entire class.
B) The entire program.
C) Only the method it belongs to.
Show Answer
C) Only the method it belongs to.
Intermediate
127.
Fix the initialization error in this code:
public void test() {
    String s;
    if (Math.random() > 0.5) { s = "High"; }
    System.out.println(s); // Error: s might not be initialized
}
Show Answer
Fix: String s = ""; (or String s = null;) at the top.
Easy
128.
When using java.awt.Graphics, in which direction does the Y-axis increase?
A) Up
B) Down
Show Answer
B) Down.
Easy
129.
Which method is the "entry point" of any Java program?
Show Answer
public static void main(String[] args)
Intermediate
130.
If you want to draw a filled oval that fits inside a box starting at (0,0) with width 50 and height 50, what method do you call?
Show Answer
g.fillOval(0, 0, 50, 50);
Harder than Easy
131.
Why is System.out.println valid code?
(Hint: System is a class. out is a _____ variable inside that class).
Show Answer
Static. (out is a public static member of the System class).
Easy
132.
True or False: A static variable can be accessed by class name, e.g., Hero.powerLevel.
Show Answer
True.
Intermediate
133.
You have a class MathHelper. You want a constant PI equal to 3.14 that everyone can read but no one can change. How do you declare it?
Show Answer
public static final double PI = 3.14;
Easy
134.
Which import statement is typically needed to handle events or GUI components?
A) import java.util.*;
B) import javax.swing.*;
Show Answer
B) import javax.swing.*;
Harder than Easy
135.
If count is a static variable, and you increment it in the constructor of a class, what does count essentially track?
Show Answer
Total Objects: It tracks the total number of objects of that class created so far.