1. (5 points) For each of the statements below, indicate whether they are true o
ID: 3872844 • Letter: 1
Question
1. (5 points) For each of the statements below, indicate whether they are true or false by writing “T” or “F” on the provided line. Read the questions very carefully.
(a) Each Java class must contain at least one global variable.
(b) Java assigns a default value to a primitive data member of a class if the data is not initialized. (int, float, double, char, etc. are examples of primitive data types.)
(c) A static variable of an instance of a class cannot be modified by any class other than the class that contains the static variable.
(d) If the non-arg constructor is missing in a class, the default constructor is created.
(e) If Circle is a class, Circle[] circles=new Circle[10]; will call the default constructor ten times with argument value 10.
Explanation / Answer
(a) Each Java class must contain at least one global variable.
False. We can run a java class without global variable. For eg. If we want to print a simple line in java we do not require any global variable
(b) Java assigns a default value to a primitive data member of a class if the data is not initialized. (int, float, double, char, etc. are examples of primitive data types.)
True
(c) A static variable of an instance of a class cannot be modified by any class other than the class that contains the static variable.
False
(d) If the non-arg constructor is missing in a class, the default constructor is created.
True
(e) If Circle is a class, Circle[] circles=new Circle[10]; will call the default constructor ten times with argument value 10.
False
Data Type Default Value (for fields) byte 0 short 0 int 0 long 0L float 0.0f double 0.0d char 'u0000' String (or any object) null boolean falseRelated Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.