19. Given the following listing of the Widget class:
1 class Widget extends Thingee{
2 static private int widgetCount = 0 ;
3 public String wName ;
4 int wNumber ;
5
6 static synchronized int addWidget(){ widgetCount++ ;
7 wName = "I am Widget # " + widgetCount ;
8 return widgetCount ;
9 }
10 public Widget(){
11 wNumber = addWidget();
12 }
13 }
What happens when we try to compile the class and use
multiple Widget objects in a program?
Select 1 correct answer:
A. The class compiles and each Widget will get a unique wNumber
and wName reflecting the order in which the Widgets were created.
B. The compiler objects to line 7
C. A runtime error occurs in the addWidget method