If you are not sure of these answers look up in any text you are using: Creating
ID: 3792244 • Letter: I
Question
If you are not sure of these answers look up in any text you are using: Creating an object Printing output using system. out accessor and mutator methods constructor method Suppose you have written a class definition for a Student class. Write the line of code you would use to declare a reference to a Student object. Write the line of code you would use to create a Student object and assign its address to the reference you declared in question 1. You do not have to send any parameters to the Student class constructor. Suppose in the Student class there is a method that returns the student's id. Write the line of code to print the student's id to the screen using this getter method. What is the purpose of mutator (setter) methods? What is the purpose of (getter) methods)? What is the starting point for the execution of a Java project? What is the purpose of a constructor method for a class definition? Most of the time fields have _____ access and methods have _____Explanation / Answer
Q1 reference to student object
Student stud;
Q2 Student stud1 = new Student();
stud = stud1;
Q3 stud.getId();
(where stud is object of Student class
Student stud = new Student();
Q4 setter method is used to set the value of class data members
Suppose in class Student there is setter method with the following definition
public void setId(int id) {
this.id = id;
}
And we have student object stud
stud.setId(123); // will set the value of id as 123 for stud object
Q5 the getter method is used to get the value of class data members
Eg stud.getId();
Q6 main() is the starting point of the java project
Q7 Constructor is used to initialize java objects and their data members.
It is of the same name as of class without any return type.
Q8 most of the time fields have private access and methods have public access.
Q9 true
Q10 Primitive types and non primitive types
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.