AP Computer Science A Question of the Day

Daily challenge for AP Computer Science A. Test yourself and track progress.

USING STATIC VARIABLES

CONSIDER THE FOLLOWING JAVA CODE:

**public class Employee**

**{**

static int nextID = 1;

String name;

int employeeID;

``

Employee(String n){

name = n;

employeeID = nextID;

nextID++;

}

public String getName(){

return name;

}

public int getID(){

return employeeID;

}

public static void main(String[] args)
{

Employee emp3 = new Employee("Kate");

Employee emp1 = new Employee("John");

Employee emp2 = new Employee("Sandy");

System.out.println(emp1.getName() + " ID: " + emp1.getID());

System.out.println(emp3.getName() + " ID: " + emp3.getID());

}

**}**

WHAT WOULD BE THE CONSOLE OUTPUT?

Select an answer and click Check.