Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Name the class component and give a brief description in your own words the purp

ID: 3841651 • Letter: N

Question

Name the class component and give a brief description in your own words the purpose it serves.
Please answer accordingly like
"A: (what it is and description)"
"B: (what it is and description)" etc

class student{ int id; String name; String city; student (int id, String name){ this.id = id; this.name = name; } student(int id, String name, String city) { this.id = id; this.name = name; this.city = city; } void print( ){ System.out.println(id + + name + + city); } } public class ThisDemo4 { public static void main(String[ ] args) { student malestudent = new student(111, John); student femalestudent = new student (321, Mary, Oakland); malestudent.print ( ); femalestudent.print ( ) ; } }

Explanation / Answer

A: These are called as the data members of a class. Data members of a class are used to store data related to the user defined class. Their degree of access can be determined by the three access specifiers – private, protected and public.

B: ’this’ is a reference variable that refers to the current instance of the class (or object). It is also used to invoke current member functions and/or constructors of a class.

C: These are arguments of string type passed to a constructor. These store the values of name and city passed by the object on creation and are used inside the constructor for initialization.

D: These are constructors. These are used to initialize the data members of the class with the passed arguments whenever an object of class is created. When an object is passing one argument, the above constructor is invoked and if it is passing two then the constructor below that is invoked.

E: These are the objects of class student. They are used to access the data members and member functions of the class using the ’.’ operator. The objects with arguments are passing values of data members which will be initialized by the constructor.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at drjack9650@gmail.com
Chat Now And Get Quote