Question: public static void main ( String [ ] args ) { / / Scanner for user input Scanner scanner = new Scanner ( System .
public static void mainString args
Scanner for user input
Scanner scanner new ScannerSystemin;
Default Constructor Case
Apple appleDefault new Apple;
System.out.printlnDefault Constructor: appleDefault.toString;
Parameterized Constructor with Valid Type
Apple apple new AppleRed Delicious", ;
System.out.printlnParameterized Constructor Valid Type: appletoString;
Parameterized Constructor with Invalid Type
Apple apple new AppleInvalid Type", ;
System.out.printlnParameterized Constructor Invalid Type: appletoString;
Setting Weight within Valid Range
applesetWeight;
System.out.printlnSet Weight Valid: applegetWeight;
Setting Weight Outside Valid Range
applesetWeight;
System.out.printlnSet Weight Invalid: applegetWeight;
Setting Price to Valid Value
applesetPrice;
System.out.printlnSet Price Valid: applegetPrice;
Setting Price to Invalid Value
applesetPrice;
System.out.printlnSet Price Invalid: applegetPrice;
toString Method
System.out.printlntoString Method: appletoString;
Equality Check with Same Properties
Apple apple new AppleRed Delicious", ;
System.out.printlnEquality Check Same Properties: appleequalsapple; true
Equality Check with Different Properties
System.out.printlnEquality Check Different Properties: appleequalsapple; false
Close the scanner
scanner.close;
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
