Java Programming Competition I

25 Questions | Total Attempts: 1007

SettingsSettingsSettings
Please wait...
Java Programming Competition I

.


Questions and Answers
  • 1. 
    What is the range of an int data type in Java?
    • A. 

      –2^15 to 2^15 – 1

    • B. 

      0 to 2^15

    • C. 

      –2^31 to 2^31 – 1

    • D. 

      0 to 2^31

  • 2. 
    What is the meaning of variable++   ? 
    • A. 

      Add one to the variable.

    • B. 

      Add one to the variable after its current value has been used.

    • C. 

      Add one to the variable before using its value.

    • D. 

      Double the value in the variable.

  • 3. 
    Consider the following line of Java code.    int x = 1+7*2; What will be the value of x at the end of execution of the line of code? 
    • A. 

      9

    • B. 

      15

    • C. 

      16

    • D. 

      21

  • 4. 
    The Java expression: !((b != 0) || (c <= 5)) is equivalent to: 
    • A. 

      (!(b = 0)) && (!(c>5))

    • B. 

      (b==0) && (c >5)

    • C. 

      (b!=0) && (c

    • D. 

      !((b 0) && (c

  • 5. 
    What does the following program output to the monitor:                   int value = 0, count = 1;                  value = count++ ; System.out.println("value: "+ value  + “count: " + count );   
    • A. 

      Value: 0 count: 0

    • B. 

      Value: 0 count: 1

    • C. 

      Value: 1 count: 1

    • D. 

      Value: 1 count: 2

  • 6. 
    What is the output of the following:                 int a = 0, b = 10;                a = --b ; System.out.println("a= " + a + "  b= " + b ); 
    • A. 

      A= 9 b=11

    • B. 

      A= 10 b= 9

    • C. 

      A= 9 b=9

    • D. 

      A= 0 b=9

  • 7. 
    Which of the answers does the same thing as the following: value += sum++ ;  
    • A. 

      Value = value + sum; sum = sum + 1;

    • B. 

      Sum = sum + 1; value = value + sum;

    • C. 

      Value = value + sum;

    • D. 

      Value = value + ++sum;

  • 8. 
     What is the name for an application that changes a human-readable programming language into a machine-readable language?  
    • A. 

      Compiler

    • B. 

      Converter

    • C. 

      Encoder

    • D. 

      Interpreter

  • 9. 
    What kind of programming language is Java?
    • A. 

      An object-oriented programming language

    • B. 

      An array programming language

    • C. 

      A logic programming language

    • D. 

      A database programming language

  • 10. 
    What is the result of evaluating the following expression?     (1/2 + 3.5) * 2.0  
    • A. 

      8

    • B. 

      7.0

    • C. 

      6.0

    • D. 

      None of the above

  • 11. 
    The && operator works with which data types?  
    • A. 

      Int

    • B. 

      Long

    • C. 

      Double

    • D. 

      Boolean

  • 12. 
    Which one of the following is NOT a correct variable name? 
    • A. 

      2bad

    • B. 

      Zero

    • C. 

      TheLastValueButOne

    • D. 

      Year2000

  • 13. 
    Does every Java variable use a data type? 
    • A. 

      No---only numeric variables use data types.

    • B. 

      No---data types are optional.

    • C. 

      Yes---all variables are of the same data type.

    • D. 

      Yes---each variable must be declared along with its data type.

  • 14. 
    When you compile a Java program, what are you doing?
    • A. 

      Saving it to disk

    • B. 

      Converting it into a form the computer can better understand

    • C. 

      Adding it to your program collection

    • D. 

      Converting it to object file

  • 15. 
    What is a variable?
    • A. 

      Something that wobbles but doesn't fall down.

    • B. 

      Text in a program that the compiler ignores.

    • C. 

      A place to store information in a program.

    • D. 

      An expression use in Java programming.

  • 16. 
    What is the process of fixing errors called?
    • A. 

      Defrosting

    • B. 

      Debugging

    • C. 

      Decomposing

    • D. 

      Compiling

  • 17. 
    What do you call a group of statements contained with an opening bracket and a closing bracket?
    • A. 

      A block statement

    • B. 

      Groupware

    • C. 

      Bracketed statements

    • D. 

      Not in the list provided

  • 18. 
    What is the output of the following program fragment?  for ( int j = 0;  j <  5; j++ ) {        System.out.print( j + " " ); } System.out.println( );  
    • A. 

      0 1 2 3 4 5

    • B. 

      0 1 2 3 4

    • C. 

      0 1 2 3 4 5

    • D. 

      J j j j j

  • 19. 
    What is the output of the following code fragment?  for ( int j = 10;  j >  5; j-- ) {      System.out.print( j + " " ); } System.out.println( );
    • A. 

      10 11 12 13 14 15

    • B. 

      9 8 7 6 5 4 3 2 1 0

    • C. 

      10 9 8 7 6 5

    • D. 

      10 9 8 7 6

  • 20. 
    What must the test be so that the following fragment prints out the integers from 5 through 15?  for ( int j = 5;  ________ ; j++ ){     System.out.print( j + " " ); }System.out.println( );
    • A. 

      J

    • B. 

      J

    • C. 

      j

    • D. 

      J==15

  • 21. 
    What must the change be so that the following fragment prints out the even integers 0 2 4 6 8 10?  for ( int j = 0; j <= 10; _______   )     System.out.print( j + " " ); System.out.println( );
    • A. 

      J+2

    • B. 

      J = j+2

    • C. 

      J++++

    • D. 

      ++j++

  • 22. 
    What must the initialization be so that the following fragment prints out the integers -3 -2 -1 ?  for ( _______; j < 0; j++    )   System.out.print( j + " " );   System.out.println( );
    • A. 

      int j = 0

    • B. 

      Int j < 0

    • C. 

      Int j = -3

    • D. 

      int j = -4

  • 23. 
    What is the output of the following code fragment?  for ( int j = 5;  j > -5; j-- )   System.out.print( j + " " );     System.out.println( );  
    • A. 

      -5 -4 -3 -2 -1 0

    • B. 

      5 4 3 2 1 0

    • C. 

      5 4 3 2 1 0 -1 -2 -3 -4 -5

    • D. 

      5 4 3 2 1 0 -1 -2 -3 -4

  • 24. 
     What is the output of the following code fragment?  int count = 0; for ( ;  count < 9; ++count )          System.out.print( count + " " );
    • A. 

      0 1 2 3 4 5 6 7 8

    • B. 

      Nothing --- the program will not compile.

    • C. 

      0 1 2 3 4 5 6 7

    • D. 

      1 2 3 4 5 6 7 8 9

  • 25. 
    What does this code print on the monitor?         int count = 7;                                          while ( count >= 4 )  {            System.out.print( count + " " );  count = count - 1;       } System.out.println(  );  
    • A. 

      1 2 3 4 5 6 7

    • B. 

      7 6 5 4

    • C. 

      6 5 4 3

    • D. 

      7 6 5 4 3