JAVA TRUE/FALSE. Write \'T\' if the statement is true and \'F\' if the statement
ID: 3736647 • Letter: J
Question
JAVA
TRUE/FALSE. Write 'T' if the statement is true and 'F' if the statement is false With a reason.
1) An object can store data.
2) A class in not an object, but a description of an object.
3) An access specifier indicates how the class may be accessed.
4) A method that stores a value in a class's field or in some other way changes the value of a field is known as a mutator method.
5) Instance methods should be declared static.
6) A constructor is a method that is automatically called when an object is created.
7) Shadowing is the term used to describe where the field name is hidden by the name of a local or parameter variable.
8) The public access specifier for a field indicates that the attribute may not be accessed by statements outside the class.
9) A method that gets a value from a class's field but does not change it is known as a mutator method.
10) Instance methods do not have the key word static in their headers.
11) The term "default constructor" is applied to the first constructor written by the author of a class.
12) When a local variable in an instance method has the same name as an instance field, the instance field hides the local variable.
13) The term "no-arg constructor" is applied to any constructor that does not accept arguments.
14) The java.lang package is automatically imported into all Java programs.
Explanation / Answer
1. True.
An object can store data. An object consist of one or more fields which stores data.
2. True
Class is a blueprint of object. It defines what properties the object will have but it is not an object itself.
When it is instantiated, then objects are created.
3. True
Access specifier indicates by what level the class is accessible. It could be within the package or public or not accessible outside file.
4. True
Method which changes the value of a class field is called as mutator method because it is mutating (changing) the value.
5. False
Instance methods belongs to instances i.e. objects of the class, and not the class directly. Hence, they should not be static methods. (Static methods are the ones which can be refered directly by class and does not need an instance of class to be referred.)
6. True
Object creation automatically calls the constructor to construct it.
7. True
when a local of parameter variable is of the same name as that of a field and tries to hide the field name, it is called shadowing.
8. False
public access specifier implies a public access i.e. from anywhere even outside the class also.
9. False
Mutator method is the one which changes the class field's value
10. True
instance methods are non-static in nature.
11. False
Default constructor can be a constructor written in any order in the class but it does not have any parameters.
One which has paramters in its signature is the parametrized constructor.
12. False
Instance field never hides the local variable. It is the other way around, local variable hides the instance field.
13. True
any constructor that does not have any arguments in its signature is "no-arg constructor"
14. True
This is the behaviour defined by Java.
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.