175k views
5 votes
Insert XXX to output the student's ID. public class Student { private double myGPA; private int myID; public getID) { return myID; public static void main(String [] args) { Student s = new Studento; XXX System.out.println("Student ID: "); System.out.println("Student ID:" + getID()); System.out.println("Student ID:" + s.getId()); System.out.println("Student ID:" + student.getID()); A static main() _ has direct access to class instance members can declare and create objects can call instance methods without an object O can not be included within a programmer-defined class What is stored in score1, score2, and grade? Integer scorel = 72; int score2 = 85; Character grade = 'C'; obj reference, 85, obj reference 72,85, obj reference, obj reference, obj reference obj reference, obj reference, Which is true? Instances of programmer-defined objects are immutable Contents of a Double instance can be modified after initialization An instance of String stores data rather than an object reference Reference variables store memory locations

User Will Walsh
by
4.0k points

1 Answer

4 votes

Answer:

Step-by-step explanation:

The question above is missing many details and are actually various questions in one. I will answer each one seperately below...

A. The piece of code to get the ID in this code snippet that needs to replace XXX would be the following ... System.out.println("Student ID: " + s.getID());

B. A static main() can declare and create objects. Once these objects are created their instance methods can then be called.

C. Integer score1 = 72;

int score2 = 85;

Character grade = 'C';

In the above code snippet, the information stored in score1, score2, and grade are the following... obj reference, 85, obj reference. This is becasue both Integer and Character are classes and the values being passed to their variables are referencing that object class, while score2 is a primitive type of int and is therefore simply a number.

D. The statement that is true is ... Contents of a Double instance can be modified after initialization. Objects can be modified by calling its setter methods after initializing it.

User Rohit Luthra
by
5.3k points