Question: Create a Java class named StudentProfile. This class will manage student profile information, including their name, age, major, and university. You need to implement a
Create a Java class named StudentProfile. This class will manage student profile information, including their name, age, major, and university. You need to implement a constructor that initializes all these fields at the time of object creation.
Class Structure:
Private Variables:
A private String variable name to hold the student's full name.
A private int variable age to hold the student's age.
A private String variable major to represent the student's major field of study.
A private String variable university to store the name of the university the student attends.
Constructor:
Define a constructor that accepts four parameters that are used to set name, age, major, and university in this order
Getters:
Implement a getter method for each private variable getName getAge, getMajor, getUniversity that returns the respective field's value.
Main Method: Write a main method in your class that creates a StudentProfile object referenced by a variable studentProfile. Use the class constructor so that the student's name is "John", age is major is "Computer Science", and university is "MIT".
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
