Question: Define a default constructor that initializes the fields name ( string ) and height ( double ) with the default values Void and - 1
Define a default constructor that initializes the fields name string and height double with the default values "Void" and respectively.
Ex: If the input is Bob then the output is:
Default values:
Name: Void, Height:
After mutator methods:
Name: Bob, Height:
Note: The class's print method is called before and after the input is passed to the setters. public class Student
private String name;
private double height;
Your code goes here
public void setNameString studentName
name studentName;
public void setHeightdouble studentHeight
height studentHeight;
public void print
System.out.printName: name;
System.out.printf Height: f
height;
StudentList.java: import java.util.Scanner;
public class StudentList
public static void mainString args
Scanner scnr new ScannerSystemin;
String newName;
double newHeight;
Student favoriteStudent new Student;
System.out.printlnDefault values: ;
favoriteStudent.print;
newName scnrnext;
newHeight scnrnextDouble;
favoriteStudent.setNamenewName;
favoriteStudent.setHeightnewHeight;
System.out.printlnAfter mutator methods: ;
favoriteStudent.print;
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
