Welcome to your Foundation Test - 2 Code - 819

Name
Email
Phone
1.

Question: You want to find out whether two strings are equal or not,  in terms of the actual characters within the strings. What is the best way to do this?

Select 1 option(s):
2.

Question: What will the following code print?

String abc = "";
abc.concat("abc");
abc.concat("def");
System.out.print(abc);

Select 1 option(s):
3.

Question: How will you initialize a SimpleDateFormat object so that the following code will print the full name of the month of the given date?

    System.out.println(sdf.format(new Date()));

Select 1 option(s):
4.

Question:

Given the following code:

abstract class Device{
    String name;
    String number;
    String address;
    int frequency;
    
    abstract void setName(String name);
    abstract void connect();
    abstract void disconnect();
    abstract void call(String number);
    abstract void listenOn(int frequency);
    
}

interface Caller{     }

interface Receiver{    }

class Phone extends Device implements Caller{ }
class TV extends Device implements Receiver{ }
class WalkieTalkie extends Device implements Caller, Receiver{ }

and the following requirements specification:
1. Phone supports only the call operation. Users should have the ability to call a number, but not set the frequencey. Assume frequency is fixed at 0.

2. TV supports only the listenOn operation. Users should have the ability to set the frequency using the listenOn method, but not change the number. Assume number is fixed at "0".

3. WalkieTalkie contains both call and listenOn features. Users should have the ability to call a number using call as well as set frequency using listenOn.

Which two changes together would allow you to achieve these specifications?

Select 2 option(s):
5.

Question: Which of the following are true about the "default" constructor?

Select 1 option(s):
6.

Question: Which of the following is/are valid double values for 10 million? (A million has 6 zeros)

Select 1 option(s):
7.

Question: Which of the following are true about the "default" constructor?

Select 2 option(s):
8.

Question: Which of the following are also known as "short circuiting logical operators"?

Select 2 option(s):
9.

Question:

Identify correct statements about a two dimensional array.

Select 1 option(s):
10.

Question:

Consider the following class...

class MyString extends String{
   MyString(){ super(); }
}


The above code will not compile.

Select 1 option(s):
11.

Question:

Identify examples of autoboxing.

Select 3 option(s):
12.

Question: What class of objects can be declared by the throws clause?

Select 3 option(s):
13.

Question:

Identify the concrete classes that can be used to store key - value pairs?

Select 2 option(s):
14.

Question: Which interfaces does java.util.NavigableMap extend directly or indirectly?

Select 2 option(s):
15.

Question:

Consider the following code written by a new developer:

while(true){
        //additional valid code
        if(isDone()) break;
}


What can be done to make this code more readable?

Select 1 option(s):
16.

Question: Which one of these is a proper definition of a class Car that cannot be sub-classed?

Select 1 option(s):
17.

Question: Which of the following standard functional interfaces returns void?

Select 1 option(s):
18.

Question:

Given the following declaration, select the correct way to get the number of elements in the array, assuming that the array has been initialized.

int[] intArr;

Select 1 option(s):
19.

Question:

A method with no access modifier defined in a class can be overridden by a method marked protected (assuming that it is not final) in the sub class.

Select 1 option(s):
20.

Question: Which of the following elements is/are a must in a stream pipeline?

Select 2 option(s):
21.

Question: Which import statements are required to compile the following code?

public class TestClass
{
    public static void main(String[] args) throws Exception
    {
        LocalDate d = LocalDate.of(2020, 1, 2);
        DateTimeFormattter df = DateTimeFormatter.ofPattern("yyyy MMM dd");
    }
}

Select 2 option(s):
22.

Question: Which of the following tools support the --show-module-resolution option?

Select 1 option(s):
23.

Question: Where, in a constructor, can you place a call to a super class's constructor ?

Select 1 option(s):
24.

Question: Which of these statements are true?

Select 2 option(s):
25.

Question: In which of the following cases can the Console object be acquired?

Select 1 option(s):
26.

Question: Which of the following are required to construct a Locale?

Select 1 option(s):
27.

Question: Which of the following collection implementations are thread-safe?

Select 1 option(s):
28.

Question: Which of the following access control keywords can be used to enable all the subclasses to access a method defined in the base class?

Select 2 option(s):
29.

Question: Which of the following statements are true?

Select 2 option(s):
30.

Question: Which of the following are correct about java.util.function.Predicate?

Select 1 option(s):
31.

Question: Which of the following method calls can be applied to a String object?

Select 4 option(s):
32.

Question: Which of the following are valid declarations in a class?

Select 1 option(s):
33.

Question: What is meant by "encapsulation" ?

Select 1 option(s):
34.

Question:

Identify the correct statement about i18n.

Select 2 option(s):
35.

Question: Which of the following interface is suitable for a class that stores associations of keys to values?

Select 1 option(s):
36.

Question:

Identify the correct statements regarding JDBC.

Select 1 option(s):
37.

Question:

Your application requires to store name value pairs such that the order of entries returned while iterating through the structure is deterministic. In other words, if you iterate over the same structure twice, the order of elements returned in both the iterations will be the same. Which of the following classes would you use?

Select 2 option(s):
38.

Question:

Consider the following variable declaration within the definition of an interface:
  int i = 10;
Which of the following declarations defined in a non-abstract class, is equivalent to the above?

Select 1 option(s):
39.

Question:

Your new question: Which of the following interfaces can be used to store a collection of non-duplicate/unique objects in an unordered fashion ?

Select 1 option(s):
40.

Question: Which of the following options can be a part of a correct inner class declaration or a combined declaration and instance initialization ?

(Assume that SimpleInterface and ComplexInterface are interfaces.)

Select 2 option(s):
41.

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

Select 2 option(s):
42.

Question:

Your application needs to load a set of key value pairs from a database table which never changes. Multiple threads need to access this information but none of them changes it.

Which class would be the most appropriate to store such data if the values need not be kept in a sorted fashion?

Select 1 option(s):
43.

Question: Which of these statements are true?

Select 3 option(s):
44.

Question: Which of the following are standard Java annotations?

Select 2 option(s):
45.

Question:

Consider the following code:

public class MyClass {

  protected int value = 10;

}

Which of the following statements are correct regarding the field value?

Select 1 option(s):
46.

Question:

A try-with-resources statement requires ......

Select 1 option(s):
47.

Question: Which of these statements are true?

Select 2 option(s):
48.

Question:

An instance member ...

Select 2 option(s):
49.

Question: Which of the following are benefits of an array over an ArrayList ?

Select 2 option(s):
50.

Question: 

You are modeling a class hierarchy for living things. You have a class LivingThing which has an abstract method reproduce().

Now, you want to have 2 concrete subclasses of LivingThing - Plant and Animal. Both do reproduce but the mechanisms are different. What would you do?

Select 1 option(s):
51.

Question:

Given:

public class Employee{
          String name;
          public Employee(){
    }
}

Which of the following lines creates an Employee instance?

Select 1 option(s):
52.

Question:

Anonymous inner classes always extend directly from the Object class.

Select 1 option(s):
53.

Question: Which variables of the encapsulating class can an inner class access, if the inner class is defined in an instance method of the encapsulating class?

Select 4 option(s):