Welcome to your Foundation Test - 1 Code - 819

Name
Email
Phone
1.

Question: Using a Callable would be more appropriate than using a Runnable in which of the following situations?

Select 1 option(s):
2.

Question: How can you declare a method someMethod() such that an instance of the class is not needed to access it and all the members of the same package have access to it.

Select 3 option(s):
3.

Question: Given that a code fragment has just created a JDBC Connection and has executed an update statement, which of the following statements is correct?

Select 1 option(s):
4.

Question: Which of the following are valid command line options and their one character shortcuts related to the Java module system?

Select 2 option(s):
5.

Question: Which of the following statements concerning the switch construct are true?

Select 3 option(s):
6.

Question: Which of these statements concerning nested classes and interfaces are true?

Select 3 option(s):
7.

Question: Which of the following is a legal return type of a method overriding the given method:

public Object  myMethod() {...}

Select 1 option(s):
8.

Question: Which of the following annotations are retained for run time?

Select 3 option(s):
9.

Question: Using a continue in a while loop causes the loop to break the current iteration and start the next iteration of the loop.

Select 1 option(s):
10.

Question:

Given the following code, which statements are true?

class A{
   int i;
}
class B extends A{
   int j;
}

Select 3 option(s):
11.

Question: Which of the following statements are correct regarding a functional interface?

Select 1 option(s):
12.

Question: Which of the following statements are true?

Select 3 option(s):
13.

Question: An anonymous class can be declared in a static method.

Select 1 option(s):
14.

Question:

Consider the following class:

public class Test{ public int id; }

Which of the following is the correct way to make the variable 'id' read only for any other class?

Select 1 option(s):
15.

Question: Which of these methods are defined in the Map interface?

Select 2 option(s):
16.

Question: Which of these statements concerning interfaces are true?

Select 2 option(s):
17.

Question:

A try without resources statement must always have a ............. associated with it.

Select 1 option(s):
18.

Question: Which statements concerning the relation between a non-static inner class and its outer class instances are true?

Select 3 option(s):
19.

Question: You are implementing a special sorting algorithm that can sort objects of different classes. Which of the following class declarations will you use?

Select 1 option(s):
20.

Question: Which of the following statements regarding inner classes are true ?

Select 3 option(s):
21.

Question: Which statements concerning conversion are true?

Select 4 option(s):
22.

Question: Which of the following statements are correct?

Select 1 option(s):
23.

Question: What will the following code print?

void crazyLoop(){ var c = 0; JACK: while (c < 8){ JILL: System.out.println(c); if (c > 3) break JACK; else c++; } }

Select 1 option(s):

24.

Question: Which of the following are true about a try/catch statement?

Select 1 option(s):
25.

Question: Which of these statements concerning the charAt() method of the String class are true?

Select 2 option(s):
26.

Question: Which of the following is/are valid functional interfaces?

Select 1 option(s):
27.

Question: Which of these combinations of switch expression types and case label value types are legal within a switch statement?

Select 1 option(s):
28.

Question: Which clause(s) are used by a module definition that uses a service?

Select 2 option(s):
29.

Question:

The following code snippet will print 'true'.

short s = Short.MAX_VALUE;
char c = s;
System.out.println( c == Short.MAX_VALUE);

Select 1 option(s):
30.

Question:

Compared to public, protected, and private accessibilities, default accessibility is....

Select 1 option(s):
31.

Question: Which of the following are wrapper classes for primitive types?

Select 1 option(s):
32.

Question: Which of the following are NOT valid operators in Java?

Select 4 option(s):
33.

Question: Which of these statements are valid when occurring by themselves in a method?

Select 3 option(s):
34.

Question: Which of these statements concerning the use of modifiers are true?

Select 1 option(s):
35.

Question:

Code that uses generic collection classes can interoperate with code that uses raw collections classes because of?

Select 1 option(s):
36.

Question: Which of the following standard functional interfaces is most suitable to process a large collection of int primitives and return processed data for each of them?

Select 1 option(s):
37.

Question: Which of the following statements are true?

Select 2 option(s):
38.

Question: Which of the following statements regarding 'break' and 'continue' are true?

Select 1 option(s):
39.

Question:

Consider the following directory structure and the files contained in the directories:

c:\javatest
  +- <src>
       +- <foo.bar>
             +- <foo>
                 +- <bar>
                       -- BazA.java
                       -- BazB.java


Assuming that the package name specified in BazA and BazB is foo.bar, which of the following statements are correct?

Select 1 option(s):
40.

Question: Which of the following statements are true?

Select 1 option(s):
41.

Question: Which of these implementations for collection framework interfaces are provided in the standard JDK?

Select 3 option(s):
42.

Question: What will the following program print when run?

public class TestClass{
  public static void main(String[] args){
     try{
        System.exit(0);
     }
     finally{
         System.out.println("finally is always executed!");
     }
  }
}

Select 1 option(s):
43.

Question:

Given that TestClass is a class, how many objects and reference variables are created by the following code?

TestClass t1, t2, t3, t4;
t1 = t2 = new TestClass();
t3 = new TestClass();

Select 1 option(s):
44.

Question:

Identify the correct statement regarding a JDBC Connection:

Select 1 option(s):
45.

Question: You have been given an instance of an Executor and you use that instance to execute tasks. How many threads will be created for executing these tasks by the Executor?

Select 1 option(s):
46.

Question:

You have a method that currently does not handle any exception thrown from the code contained in its method body. You are now changing this method to call another method that throws IOException.

What changes, independent of each other, can you make to your method so that it will compile?

Select 2 option(s):
47.

Question: Which of the following command line switches is required (independent of each other) to run a modular application stored in c:\modules\movies.jar?

Select 3 option(s):
48.

Question:

Consider the following code:

public static void main(String[] args) {
   int[] values = { 10, 30, 50 };
   for( var val : values ){
       var x = 0;
       while(x<values.length){
            System.out.println(x+" "+val);
             x++;
        }
   }              
}


How many times is 2 printed out in the output?

Select 1 option(s):
49.

Question: Is it possible to create arrays of length zero?

Select 1 option(s):
50.

Question: Which of the following statements are true?

Select 2 option(s):
51.

Question: What will the following code print?

        var rlock = new ReentrantLock();
        var f1 = rlock.lock();
        System.out.println(f1);
        var f2 = rlock.lock();
        System.out.println(f2);

Select 1 option(s):
52.

Question: You want to execute your tasks after a given delay. Which ExecutorService would you use?

Select 1 option(s):
53.

Question: What will the following code print?

public class TestClass{

   static char ch;
   static float f;
   static boolean bool;

   public static void main(String[] args){
      System.out.print(f);
      System.out.print(" ");
      System.out.print(ch);
      System.out.print(" ");
      System.out.print(bool);
   }
}


Select 1 option(s):