Question: 2. Given class DollApp.java below. Type and find the output. Write your answer the sheet provided. import java.util.Scanner; public class DollApp { public static void
2. Given class DollApp.java below. Type and find the output. Write your answer the sheet provided. import java.util.Scanner; public class DollApp { public static void main() { Scanner in = new Scanner(System.in); System.out.println("Creating a doll.."); Doll doll1 = new Doll(); doll1.pressMe(); doll1.setName("Rita"); doll1.pressMe(); System.out.print("Would you like to set name?Y/N:> "); char choice = in.next().charAt(); in.nextLine(); if((choice == 'Y*)||(choice == 'y')) { System.out.print("Enter the name: "); String name=in.nextLine(); doll1.setName (name); } doll1.pressMe(); } Output
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
