Ask Question
12 March, 05:57

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

+3
Answers (1)
  1. 12 March, 06:43
    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?
Get 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 there is no answer or all answers are wrong, use a search bar and try to find the answer among similar questions.
Search for Other Answers