Question: Create a class called Student with the following instance variables: name (String) age (int) Create a constructor in the Student class that takes two parameters:
Create a class called "Student" with the following instance variables:
name (String)
age (int)
Create a constructor in the Student class that takes two parameters: name and age, and sets the instance variables accordingly.
Create the following methods in the Student class:
setName(String name) - a method that sets the name instance variable.
setAge(int age) - a method that sets the age instance variable.
getName() - a method that returns the value of the name instance variable.
getAge() - a method that returns the value of the age instance variable.
In the main method of your program, create an instance of the Student class and set its name and age using the setName and setAge methods
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
