Ask Question
7 May, 01:05

Assign courseStudent's name with Smith, age with 20, and ID with 9999. Use the printAll () member method and a separate println () statement to output courseStudents's data. Sample output from the given program: Name: Smith, Age: 20, ID: 9999

+2
Answers (1)
  1. 7 May, 01:31
    0
    The solution code is written in Java. Presume that there is a Student class with three private attributes (name, age and ID). Within the Student class, there is a member method, printAll that will display the name, age and ID using the println () method.

    Student. java

    public class Student { private String name; private int age; private int ID; public Student (String name, int age, int ID) { this. name = name; this. age = age; this. ID = ID; } public void printAll () { System. out. println ("Name: " + this. name); System. out. println ("Age: " + this. age); System. out. println ("ID: " + this. ID); } }

    In the main program we create a student instance and use this instance to call the printAll member method to display the output as required by the question.

    Main. java

    public class Main { public static void main (String[] args) { Student courseStudent = new Student ("Smith", 20, 9999); courseStudent. printAll (); } }
Know the Answer?
Not Sure About the Answer?
Find an answer to your question 👍 “Assign courseStudent's name with Smith, age with 20, and ID with 9999. Use the printAll () member method and a separate println () ...” in 📗 Engineering if the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers