Skip to main content

Unit 3 · Class Creation

Classes and Constructors

Classes and Constructors MCQ Practice

Question 1 of 15

Answered 0 of 15

Choose one answer.

What is printed by the following code segment?

public class Tally
{
    private int n;
    public Tally(int start)
    {
        n = start;
    }
    public int get()
    {
        return n;
    }
}

Tally t = new Tally(4);
System.out.print(t.get());
Choose one answer.