Tag: programming languages

Questions Related to programming languages

Running thread can't come back to runnable state directly.

  1. True

  2. False


Correct Option: B
    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

You are considering four different "if" statements for the following code: public class IsItSame { public static void main(String [] args ) { int TheAnswer = 0; IsItSame x = new IsItSame(); Object y = x; IsItSame z = new IsItSame(); if (z == x) TheAnswer = 0; if (y == x) TheAnswer = 1; if (y == z) TheAnswer = 2; if (y.equals(z) ) TheAnswer = 3: if (x.equals(z) ) TheAnswer = 4; if (z.equals(y) ) TheAnswer = 5; System.out.printIn("The answer is " + TheAnswer); } } What will be printed out once the code is compiled and executed?

    1. The answer is 0
    1. The answer is 1
    1. The answer is 2
    1. The answer is 3
    1. The answer is 4

Correct Option: B

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
  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

Given: 10. public class Fabric 11. public enum Color { 12. RED(0xff0000), GREEN(0x00ff00), BLUE(0x0000ff); 13. private final int rgb; 14. Color( int rgb) { this.rgb = rgb; } 15. public int getRGB() { return rgb; } 16. }; 17. public static void main( String[] argv) { 18. // insert code here 19. } 20. } Which two code fragments, inserted independently at line 18, allow the Fabric class to compile?

  1. Color skyColor = BLUE;

  2. Color treeColor = Color.GREEN;

  3. Color purple = new Color( 0xff00ff);

  4. if( RED.getRGB() < BLUE.getRGB() ) {}

  5. Color purple = Color.BLUE + Color.RED;

  6. if( Color.RED.ordinal() < Color.BLUE.ordinal() ) {}


Correct Option: B,F
  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