0

programming languages Online Quiz - 325

Description: programming languages Online Quiz - 325
Number of Questions: 20
Created by:
Tags: programming languages
Attempted 0/20 Correct 0 Score 0

Given the following directory tree, you must enable assertions for everything except for FileTwo. base |firstLevelDirectory |_Foo |_Bar | secLevelDirectory |_FileOne |_FileTwo What command-line code should you use?

    1. java -ea -da:base.firstLevelDirectory.secLevelDirectory.FileTwo
    1. java -ea:base.firstLevelDirectory.secLevelDirectory.FileTwo -da
    1. java -ea:base... -da:base.firstLevelDirectory.secLevelDirectory...
    1. java -enableassertions -disableassertions:base.FileTwo

Correct Option: A

Which of the following options is a benefit of a Set or SortedSet? Incorrect. The correct option is as follows

    1. Use of an index
    1. Lack of duplicates
    1. Use of non-unique keys
    1. Use of unique keys

Correct Option: C

Given: 11. public class Ball { 12. public enum Color { RED, GREEN, BLUE }; 13. public void foo() { 14. // insert code here 15. { System.out.println(c); } 16. } 17. } Which code inserted at line 14 causes the foo method to print RED, GREEN, and BLUE?

  1. for( Color c : Color.values())

  2. for( Color c = RED; c <= BLUE; c++)

  3. for( Color c; c.hasNext() ; c.next())

  4. for( Color c = Color[0]; c <= Color[2]; c++)

  5. for( Color c = Color.RED; c <= Color.BLUE; c++)


Correct Option: A

which methods would prevent the execution of a thread? (Choose all that apply)

    1. sleep()
    1. yield()
    1. run()
    1. join()

Correct Option: A,B,D
  1. 1From a int to a short

  2. 2From a char to an int

  3. 3From a short to an int

  4. 4From a double to a float

  5. 5From a float to a long


Correct Option: B,C

A method is declared as protected. What classes can access this method? (Choose two. Each option is a correct answer.)

    1. Classes in the same package
    1. All classes
    1. Only the class within the package that defined the method
    1. Classes that inherit access

Correct Option: A,D
    1. It jumps out of the loop back to the calling method.
    1. It jumps out of the loop to the next statement after the loop.
    1. It stops the execution of the program and of the virtual machine.
    1. It stops the innermost iteration and continues with the next iteration of the loop.

Correct Option: B
    1. From an int to a long
    1. From a byte to an int
    1. From a short to a byte
    1. From an int to a double
  1. 5) All of the above


Correct Option: E

You are writing an assertion expression in your code. Which code is legal?

  1. 1 int z = 0;

  2. 2 assert (z = 9);

  3. 3 assert (x ==5);

  4. 4 int z = 0;

  5. 5 boolean x = true;


Correct Option: C

you assign a value to the primitive variables x and y as indicated below. Which declaration for z must be used for this code to properly compile? byte x = 3; byte y = 2; // insert declaration for z here z = x + y;

    1. byte z;
    1. int z;
    1. char z
    1. None of these options are correct

Correct Option: B

You have declared a single dimensional array of type int using the following code: int [] MyInt = new int [10]; You are attempting to initialize all of the arrays segments with a for loop using the following code: for (int x = 0; x <= 10; x++) { MyInt[x] = x; } What will happen when you attempt to compile the program that contains this code?

    1. The program will run successfully with no errors or warnings.
    1. The program will halt with a runtime exception.
    1. The program will halt with a compiler error.
    1. The program will run successfully with no errors but a warning will be generated.

Correct Option: B
    1. 0000 0000 0000 0000 0000 0000 0000 0100
    1. 0000 0000 0000 0000 0000 0000 0000 1000
    1. 0000 0000 0000 0000 0000 0000 0001 0000
    1. 0000 0000 0000 0000 0000 0000 0000 0111
    1. 0000 0000 0000 0000 0000 0000 0000 1001

Correct Option: A
- Hide questions