JAVA Multiple Choice- Choose the best answer from the choices given 1.When an ar
ID: 3736626 • Letter: J
Question
JAVA
Multiple Choice- Choose the best answer from the choices given
1.When an argument is passed by value,
A. The parameter variable holds the address of the argument.
B. The parameter variable cannot be changed.
C. The parameter variable holds a copy of the value passed to it.
D.Changes can be made to the argument variable.
2.If you do not provide initialization values for a class's numeric fields, they will
A.Cause a runtime error.
B.Contain an unknown value.
C.Be automatically initialized with 0.
D. Cause a compiler error.
3.Each time a method is invoked, the system stores parameters and local variables in an area of memory, known as _______, which stores elements in last-in first-out fashion.
A.a heap
B.a stack
C.an array
D.storage area
4.The signature of a method consists of ________.
A.method name
B.method name and parameter list
C.parameter list
D.return type, method name, and parameter list
5.Overloading is
A.writing a method that does too much processing.
B.writing a program that is too large to fit in memory.
C.having two or more methods with the same signature.
D.having two or more methods with the same name, but different signatures.
6.A method's signature consists of
A.the method name and the parameter list.
B.the return type, the method name, and the parameter list.
C.the size of the method in memory.
D.the return type and the method name.
7.The only limitation that static methods have is
A.they must be declared outside of the class.
B.they cannot refer to nonstatic members of the class.
C.they can only be called from static members of the class.
D.they can refer to only nonstatic members of the class.
8.Assuming the following declaration exists:enum Tree { OAK, MAPLE, PINE } What will the following code display? System.out.println(Tree.OAK);
A.OAK
B.Tree.OAK
C.A memory address
D.null
9.When a field is declared static, there will be
A.a copy of the field for each method in the class.
B.a copy of the field in each class object.
C.only one copy of the field in memory.
D.two reference copies of the field for each method in the class.
Explanation / Answer
1. C The parameter variable holds a copy of the value passed to it.
in pass by value, the parameter variable actually copies the data and passes that rather than the address of the actual object
2. C Be automatically initialized with 0.
class level variables are by default initialized to 0 and null values if not initialized explicitly.
3. B.a stack
the system stores parameters and local variables in the stack memory
4. D return type, method name, and parameter list
signature of the method return type, method name , arguments data types and their order.
for e.g. public static void main(String args[]) { }
5. D having two or more methods with the same name, but different signatures.
when two or more methods with the same name differ in signature based on the return type or parameters, it is termed as overloading of methods
6. B the return type, the method name, and the parameter list.
signature of the method return type, method name , arguments data types and their order.
for e.g. public static void main(String args[]) { }
7. they cannot refer to nonstatic members of the class.
static method are called when the class is loaded into memory, before initialization of its objects therefore it cannot refer anything that has not been initialized like non-static members.
8. A) OAK
It will display OAK
9. C. only one copy of the field in memory.
static fields are shared across all the objects and have only one copy of them in the memory.
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.