Knowee
Questions
Features
Study Tools

Which of the following statements is correct? Please select all that apply.   Group of answer choicesA reference variable references to an object.A data field in a class must be of a primitive type.A reference variable is an object.A data field in a class should be an instance type.

Question

Which of the following statements is correct? Please select all that apply.   Group of answer choicesA reference variable references to an object.A data field in a class must be of a primitive type.A reference variable is an object.A data field in a class should be an instance type.

🧐 Not the exact question you are looking for?Go ask a question

Solution

The correct statements are:

  1. A reference variable references to an object.
  2. A data field in a class should be an instance type.

Explanation:

  1. A reference variable in Java is used to refer to (or access) an object. It is not an object itself, but it is a way to access the actual object in memory.

  2. A data field in a class can be of any type, including primitive types (like int, char, etc.) and reference types (like String, array, etc.). It doesn't have to be a primitive type. So, this statement is incorrect.

  3. As mentioned above, a reference variable is not an object. It is a way to access an object. So, this statement is incorrect.

  4. A data field in a class can be an instance type. Instance variables (also known as non-static fields) are declared without the static keyword. They are unique for each instance (or object) of a class. So, this statement is correct.

This problem has been solved

Similar Questions

Which of the following statements are true? Please select all that apply. Group of answer choicesLocal variables do not have default values.Data fields have default values.A variable of a primitive type holds a value of the primitive type.A variable of a reference type holds a reference to where an object is stored in the memory.You may assign an int value to a reference variable.

Which of the following statements is false? Please select all that apply.Group of answer choicesA variable of a primitive type holds a value of the primitive type.A variable of a reference type holds a reference to where an object is stored in the memory.Local variables do not have default values.Since addresses are integers, we can assign an int value to a reference variable.

Which of the following statements are true? You can  select more than one statement.Group of answer choicesDefining a class creates a new data type.A class can have attributes and methods.A class is a template for entities that have common properties.A class must contain attributes.

Which statements are most accurate regarding the following classes? class A {   private int i;   protected int j; } class B extends A {   private int k;   protected int m; } Group of answer choicesAn object of B contains data fields i, j, k, m.An object of B contains data fields j, k, m.An object of B contains data fields j, m.An object of B contains data fields k, m.

In Java, which of the following statements about reference types are correct:They contain the value of the object that they refer to.A reference can be assigned to another object of the same type.A reference can be assigned to a new object by using the new keyword.They throw a compiler error if you attempt to assign them null.1, 2, and 31, 2, and 42 and 32, 3, and 4

1/3

Upgrade your grade with Knowee

Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.