Define a default constructor that initializes the fields age (integer), eyeColor (string), and name (string) with the default values 0, "Unstated", and "Unstated", respectively. Ex: If the input is 63 gray Taj, then the output is: Default values: Age: 0, Eye color: Unstated, Name: Unstated After mutator methods: Age: 63, Eye color: gray, Name: Taj Note: The class's print() method is called before and after the input is passed to the setters. Student.java public class Student { private int age; private String eyeColor; private String name; /* Your code goes here */ publicvoidsetAge(intstudentAge) { age=studentAge; } publicvoidsetEyeColor(StringstudentEyeColor) { eyeColor=studentEyeColor; } publicvoidsetName(StringstudentName) { name=studentName; } publicvoidprint() { System.out.println("Age: "+age+", Eye color: "+eyeColor+", Name: "+name); } }
OOPs
In today's technology-driven world, computer programming skills are in high demand. The object-oriented programming (OOP) approach is very much useful while designing and maintaining software programs. Object-oriented programming (OOP) is a basic programming paradigm that almost every developer has used at some stage in their career.
Constructor
The easiest way to think of a constructor in object-oriented programming (OOP) languages is:
Define a default constructor that initializes the fields age (integer), eyeColor (string), and name (string) with the default values 0, "Unstated", and "Unstated", respectively.
Ex: If the input is 63 gray Taj, then the output is:
Default values: Age: 0, Eye color: Unstated, Name: Unstated After mutator methods: Age: 63, Eye color: gray, Name: Taj
Note: The class's print() method is called before and after the input is passed to the setters.
private int age;
private String eyeColor;
private String name;
Unlock instant AI solutions
Tap the button
to generate a solution








