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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!