2.1.1. ObjUse-WE1-P1ΒΆ
Subgoals for using objects (creating instances)
Declare variable of appropriate class datatype.
Assign to variable: keyword new, followed by class name, followed by ().
Determine whether parameter(s) are appropriate (API)
Number of parameters
Data types of the parameters
ObjUse-WE1-P1
Q1: Click on the variables (object references) in the following code
/* reads input from default - keyboard */ Scanner input = new Scanner(System.in); /* reads input from InFile stream */ Scanner foo = new Scanner(InFile);
Q2: Click on the class names (but not constructors) in the following code
/* reads input from default - keyboard */ Scanner input = new Scanner(System.in); /* reads input from InFile stream */ Scanner foo = new Scanner(InFile);
Q3: Click on the calls to the Scanner constructor in the following code
/* reads input from default - keyboard */ Scanner input = new Scanner(System.in); /* reads input from InFile stream */ Scanner foo = new Scanner(InFile);
Q4: Click on the parameters which are passed to the Scanner constructor in the following code
/* reads input from default - keyboard */ Scanner input = new Scanner(System.in); /* reads input from InFile stream */ Scanner foo = new Scanner(InFile);
You have attempted of activities on this page