Sun Java Solaris Communities My SDN Account Join SDN
 
Quizzes

Language Essentials

 

Duke

This Language Essentials Quiz offers a way to test the knowledge you learned about the Java programming language from the Language Essentials Short Course. For additional help on the Java programming language, be sure to check out the Language FAQ at jGuru.

 

1. Which of the following is not a valid comment in the Java programming language?
 A. int x; // a comment
 B. /*
A comment
*/
int x;
 C. /**
A comment
*/
int x;
 D. <!--
A comment
-->
int x;


2. What is the nature of data typing in the Java programming language?
 A. Strongly typed
 B. Weakly typed
 C. Untyped


3. What is the value of seasons.length for the following array?

String[] seasons = {"winter", "spring", "summer", "fall", };
 A. undefined
 B. 3
 C. 4
 D. 5


4. When you use the new keyword to create an object, where is it created?
 A. Heap
 B. Garbage collector
 C. Queue
 D. Stack


5. Which of the following loop constructs must execute their loop body at least once?
 A. while (<boolean-expression>)
  
<statements>...
 B. do
  
<statements>...
while (
<boolean-expression>);
 C. for (<init-stmts>...; <boolean-expression>; <exprs>...)
  
<statements>...


6. An overridden method can be in the same class.
 A. True
 B. False


7. Which of the following datatypes consumes the most bits to represent its range of values?
 A. boolean
 B. float
 C. long
 D. char


8. How do you force the garbage collector to run?
 A. Call System.gc()
 B. Call Runtime.gc()
 C. Either A or B
 D. There is nothing you can do


9. When multiple methods exist within the same class with different method signatures, this is known as what?
 A. Method overloading
 B. Overriding methods
 C. Message passing
 D. A headache


10. What's printed when the following program is executed:
class PrintMe {
  public void do(int character) {
    System.out.println(character+character);
  }
  public static void main (String args[]) {
    new PrintMe().do('A');
  }
}

 A. AA
 B. 130 (The ASCII value of A is 65)
 C. Does not compile