

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
CSE205- QUIZ #4 INTERFACE & ARRAY
Typology: Exams
1 / 3
This page cannot be seen from the preview
Don't miss anything!


In Java, polymorphic method binding occurs: A. at run time B. at compile time C. never D. when a programmer writes the code E. during the testing phase of software development - Answer - A. at run time In Java, a(n) ___________________ is a collection of constants and abstract methods A. polymorphic reference B. abstract class C. implementation D. interface - Answer - D. interface In order to create a class that implements an interface, the __________________ keyword is used A. extends B. interfaces C. implements D. finalizes E. abstracts - Answer - C. implements Which of the following methods are included with any object that implements the Iteratorinterface? A. next B. hasNext C. toString D. all of the above E. a and b - Answer - D. all of the above Explanation: The Iterator interface specifies that all objects that implement it must have the hasNext and next methods. Since all objects in Java are a subclass of the Objectclass, it will also include the toStringmethod Let Animal be an interface. Then it is possible to create an object by instantiating the Animal interface: true false - Answer - false Which of the following array declarations are invalid? A. int [] grades = new int[5]; B. int grades [] = new int[5]; C. int [] grades = {91,83,42,100,77};
D. all of the above are valid E. none of the above are valid - Answer - D. all of the above are valid Every Java array is a(n) _________________, so it is possible to use a foreach loop to process each element in the array. A. object B. iterator C. class D. operator E. none of the above - Answer - B. iterator What will be the output of the following code snippet? int [] array = new int[25]; System.out.println(array.length); A. 26 B. 24 C. 25 D. This code will result in a compile time error. E. This code will result in a run time error. - Answer - C. 25 Which of the following is a true statement? A. Arrays are passed as parameters to methods like primitive types. B. Arrays are passed as parameters to methods like object types. C. Arrays cannot be passed as parameters to methods. D. All of the above are true. E. None of the above are true. - Answer - B. Arrays are passed as parameters to methods like object types. Write the output generated by the following program import java.util.*; public class SomeObjects { public static void main(String[] args) { ArrayList list = new ArrayList(); list.add("ab" ); list.add("cd" ); list.add("ef" ); System.out.println(list.size( ) ); System.out.println(list.get( 1 ) ); } } A. 2