Last Updated: January 3, 2026
31 quizzes
Call the method that returns the maximum of two integers
int result = Math.(a, b);Click an option to fill the blank:
Invoke the instance method on the calculator object to multiply two numbers
int total = calculator.(x, y);Click an option to fill the blank:
Create a new thread by passing the task as a Runnable
Thread worker = new Thread();Click an option to fill the blank:
Which best describes a method in Java?
What is the return type of a method that does not return any value?
Which method signature correctly overloads this method: int calc(int a, int b)?
Given void printInfo(String name, int age), what is true about calling it?
Which is a valid use of varargs in a method declaration?
What happens when a primitive int is passed to a method in Java?
Which statement about recursion is correct?
Which best describes method overloading?
What is required in every non-void method?
Which call correctly uses a varargs method: void sendEmails(String subject, String... recipients)?
Given void adjust(Employee e), what can this method do?
Order the steps to define and use a simple instance method that calculates tax on a price
Drag and drop to reorder, or use the arrows.
Order the steps to create a recursive method that sums numbers from 1 to n
Drag and drop to reorder, or use the arrows.
What is the output of this code?
1public class Test {
2 static int add(int a, int b) {
3 return a + b;
4 }
5 public static void main(String[] args) {
6 int result = add(3, 4);
7 System.out.println(result);
8 }
9}What is the output of this code using overloaded methods?
1public class OverloadTest {
2 static String describe(int x) {
3 return "int";
4 }
5 static String describe(double x) {
6 return "double";
7 }
8 public static void main(String[] args) {
9 System.out.println(describe(5));
10 }
11}What is the output of this recursive method?
1public class RecTest {
2 static int countdown(int n) {
3 if (n == 0) return 0;
4 return 1 + countdown(n - 1);
5 }
6 public static void main(String[] args) {
7 System.out.println(countdown(3));
8 }
9}What is the output of this code about pass by value with primitives?
1public class PassTest {
2 static void change(int x) {
3 x = 99;
4 }
5 public static void main(String[] args) {
6 int value = 10;
7 change(value);
8 System.out.println(value);
9 }
10}What is the output of this code demonstrating varargs?
1public class VarTest {
2 static int countArgs(String... args) {
3 return args.length;
4 }
5 public static void main(String[] args) {
6 System.out.println(countArgs("a", "b", "c"));
7 }
8}Find the bug in this attempt to overload a method by return type only
Click on the line(s) that contain the bug.
public class Calculator { public int add(int a, int b) { return a + b; } public double add(int a, int b) { return (double) (a + b); }}Find the bug in this recursive factorial method
Click on the line(s) that contain the bug.
public class MathUtil { public static int factorial(int n) { if (n == 0) { return 0; } return n * factorial(n - 1); }}Match each method-related concept with the best description
Click an item on the left, then click its match on the right. Click a matched item to unmatch.
Match each recursion term with its role
Click an item on the left, then click its match on the right. Click a matched item to unmatch.
Complete the code to define a method that returns the larger of two double values
public class CompareUtil { public static max( x, double y) { if (x > y) { return x; } return y; }}Click an option to fill blank 1:
Complete the code so the greet method prints a personalized message
public class Greeter { public static void greet( name) { System.out.println("Hello, " + name); } public static void main(String[] args) { greet(); }}Click an option to fill blank 1:
Complete the code to use varargs for summing any number of int values
public class SumUtil { public static int sum( nums) { int total = 0; for (int n : nums) { total += n; } return total; }}Click an option to fill blank 1:
Complete the code so that updateTitle can modify the Book object's state
public class Book { private String title; public Book(String title) { this.title = title; } public void updateTitle( newTitle) { this.title = newTitle; } public String () { return title; }}Click an option to fill blank 1:
Click the line that actually changes the state of the object passed into the method
Click on the line to select.
class Counter { int value;} public class Demo { static void increment(Counter c) { c.value++; } public static void main(String[] args) { Counter counter = new Counter(); increment(counter); }}Click the line where the recursive call happens
Click on the line to select.
public class PowerUtil { public static int pow(int base, int exp) { if (exp == 0) { return 1; } return base * pow(base, exp - 1); }}