Question
1. Which of the following is true about Objects in Java? a) Local Variables implement attributes and constructors implement behaviors. b) None of these answers.
1. Which of the following is true about Objects in Java?
a) Local Variables implement attributes and constructors implement behaviors.
b) None of these answers.
c) Instance variables implement attributes and methods implement behaviors.
d) Instance variables implement attributes and constructors implement behaviors.
e) Local variables implement attributes and methods implement behaviors.
2. Which of the following statements about Java Abstract Classes and Interfaces are true?
a) all of these answers
b) all attributes in an interface, if any, must be constants (i.e. public static finals)
c) a class can extend only one abstract class, but a class can implement more than one interface
d) an interface doesn't include implementation (method bodies) for any of its method definitions
3. Which of the following is a reason to use an ArrayList instead of an array?
a) An ArrayList can grow or shrink as needed while an array is always the same size.
b) You can use a for-each loop on an ArrayList but not in an array.
c) You can store objects in an ArrayList but not in an array.
d) None of the above
4. Immediately after this statement executes what best describes the result? byte[ ] [ ] x = {1} , {2,3,4};
a) None of these answers
b) x is a reference variable that now stores the location information for an array of 2 references to 2 arrays of byte values
c) x is allocated on the stack; the resulting array is also allocated on the stack
d) x is a reference variable that now stores the location information for a two-dimensional array of byte values
e) x is a two-dimensional array of byte values
5. Which of the following is true of an abstract class in Java?
a) An abstract class can be used as the superclass in polymorphic code
b) An abstract class can only define abstract methods and cannot implement methods
c) An abstract class cannot be extended
d) An abstract class is used to instantiate abstract objects
e) None of these answers
6. When we are defining a new interface what happens if we leave out the abstract keyword in the method definitions?
a) None of these answers
b) Because all methods in an interface are abstract it would cause a compilation error
c) A compilation error would result because abstract methods are not allowed in an interface
d) Because all methods in an interface are abstract the abstract keyword must not appear
7. What is true of class variables in Java that are declared to be static?
a) They are immutable and cannot be changed
b) They are a property of every object that is an instance of the class
c) They are associated with the class in which they are declared as opposed to objects that are instances of the class
d) They are implemented on the stack
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started