Test 2 Prep 3 Questions Flashcards
True/False: A class can only implement one interface.
False
Java interfaces are allowed to have _ instance variables?
Zero, although can have final variables.
True/False: The following will compile:
Comparable aBlock = new String();
True
What is the visibility of the method below?
public interface myChoice { void shoutOutLoud(T phrase); }
public
Will the following compile?
public interface myName { String whatsMyName(String name) { return "Harsh"; } }
Will not compile
True/False: ArrayList implements at least one interface.
True
True/False: The following code will compile: List myNums = new ArrayList();
False
True/False: The following will compile:
Comparable aBlock = new Comparable();
False
What line causes the following code to fail to compile?
List myInts = new ArrayList(); myInts.add(4); myInts.add(new Integer(42)); int firstInt = myInts.get(0);
The last line.
Given an interface Gradeable and a class named CS Test, write the class declaration (first line) for the CSTest so that CSTest will use Gradeable.
public class CSTest implements Gradeable, Comparable,... { }