public class Student
{
private String firstName;
private String lastName;
private String address;
private String username;
public Student(String studentFirstName, String StudentLastName, String studentAddress String studentUsername)
{
firstName = studentFirstName;
lastName = studentLastName;
address = studentAddress;
username = studentUsername;
}
}
public void displayStudentInfo()
{
System.out.println("Name: " + firstName + " " + lastName);
System.out.println("Address: " + address);
System.out.println("Username: " + username);
}
Using the above code, call the constructor to create a new instance of the Student object named joe. The constructor method will take the four string values (first name, last name, address, username) and set the initial state of the Student object to be: firstname = "Joe", lastname = "Jones", address = "123 Oak St.", username = "JJones".
Correct Answer:
Verified
View Answer
Unlock this answer now
Get Access to more Verified Answers free of charge
Q46: How are real-life examples of inheritance similar
Q52: What are the parts of a class
Q53: Create a class named Employee with a
Q54: class Animal
{
void myDog()
{
System.out.println("Animal
Q58: Match each term with the correct statement
Q59: Match each term with the correct statement
Q65: public class Student
{
private String firstName;
private String lastName;
private
Q68: class InstanceofDemo
{
public static void main(String[]
Q69: class Vehicle {}
public class Car extends
Q71: Using a class named Student , write
Unlock this Answer For Free Now!
View this answer and more for free by performing one of the following actions
Scan the QR code to install the App and get 2 free unlocks
Unlock quizzes for free by uploading documents