1)For class hello, which are the parameter types of the equals method? a)no para
ID: 2247492 • Letter: 1
Question
1)For class hello, which are the parameter types of the equals method?
a)no parameters.
b)one parameter, type hello.
c)one parameter, type Object.
d)two parameters, both of type hello.
e)two parameters, both of type Object.
2)If two methods in the same class have the same name, which is true:
a.They must have a different number of lines of code within the method
b.They must have different return types
c.They must have different parameter types
d.The compiler must generate an error message
e.none of the above
3)Which of (a) through (d) is false:
a.A catch block for a standard (unchecked) runtime exception is optional.
b.An exception is an object.
c.A throws clause is used to throw an exception.
d.An exception handling is located inside a catch block.
e.all of the above are true
4)Consider short-circuit evaluation for each of the following statements:
boolean a = false;
boolean b = true;
boolean c = false;
boolean d;
In which of the following is d evaluated?
a.a && d
b.b && d
c.c && d
d.All the operations evaluate d
5)Which of the following is true about reference types?
a.They are initialized to 0 by default.
b.The assignment operator (=) can be used to copy the states of two objects.
c.The equality operator (==) can be used to test if the referenced objects have identical states.
d.They cannot be passed to methods.
e.all of the above are false
6)Which of (a) to (c) is false about a static class member?
a.it must be a method
b.one member is allocated for each declared class object
c.the static class member is guaranteed to be private to the class
d.two of the above are false
e.all of (a), (b), and (c) are false
7)Which of the following statements is true?
a.Any method that compiles without error is guaranteed to be logically correct.
Java provides a mechanism to distinguish between accessor and mutator methods.
c.Each class can provide a main to perform testing.
d.The keyword this is available in all methods, including static methods.
e.Every class must implement toString and equals.
8)Which of the following best describes an abstract method?
A method that is constant throughout the inheritance hierarchy.
A method definition that changes in the inheritance hierarchy, but there is a reasonable default implementation in the super class.
No reasonable default implementation can be provided, and the method must be defined in the inheritance hierarchy.
More than one method exists withing the same class that have the same name, but different parameters.
e.
none of the above
9)Which of (a) through (d) is false for the main method?
a.Each class can have its own main method.
b.The arguments passed to a main method from a command line are strings.
c.The main method must be written as the last method in the class.
d.The main method typically does not return a value
e.all of the above are true
9)Which of the following is true?
A variable must be declared immediately before its first use.
An identifier may start with any letter or any digit.
33a is not a valid identifier.
both (a) and (c) are true
all of the above are true
a)no parameters.
b)one parameter, type hello.
c)one parameter, type Object.
d)two parameters, both of type hello.
e)two parameters, both of type Object.
Explanation / Answer
1. c)one parameter, type Object. its like public boolean equals(Object obj) { }
2. c.They must have different parameter types - this is as per concept of polymosrphism.
3. c.A throws clause is used to throw an exception..
4. b.b && d - As a and c are false, So && operator will not evaluate d .
5. e.all of the above are false.
6. e.all of (a), (b), and (c) are false
7. c.Each class can provide a main to perform testing.
8. c. No reasonable default implementation can be provided, and the method must be defined in the inheritance hierarchy
9. d.The main method typically does not return a value
10. c. 33a is not a valid identifier.
5. e.all of the above are false.
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.