Beruflich Dokumente
Kultur Dokumente
Easy WeCP
Easy WeCP
Easy WeCP
Easy WeCP
Easy WeCP
Easy WeCP
Easy WeCP
Easy WeCP
Easy WeCP
Easy WeCP
Easy WeCP
Medium WeCP
Medium WeCP
Medium WeCP
Medium WeCP
Medium WeCP
Medium WeCP
Medium WeCP
Medium WeCP
Medium WeCP
Medium WeCP
Medium WeCP
Medium WeCP
Medium WeCP
Medium WeCP
Medium WeCP
Medium WeCP
Difficult WeCP
Difficult WeCP
Difficult WeCP
Difficult WeCP
Difficult WeCP
Difficult WeCP
Difficult WeCP
Difficult WeCP
QAM(E.g,: To assess basic Quality Check Good to go?(Enter: "1 or
understanding of Design Yes" if approved
principles in OOP through code otherwise, leave it
snippets) BLANK, if question does
NA not
1 qualify to get billed
NA 1
NA 1
NA 1
NA 1
NA 1
NA 1
NA 1
NA 1
NA 1
NA 1
NA 1
NA 1
NA 1
NA 1
NA 1
NA 1
NA 1
NA 1
NA 1
NA 1
NA 1
NA 1
NA 1
NA 1
NA 1
NA 1
NA 1
NA 1
NA 1
NA 1
NA 1
NA 1
NA 1
NA 1
Final Question
A class named "MyClass" contains multiple methods like Sample1(), Sample2(), Sample3() ,..Sampled().
Consider a predefined integer variable X that is to be used to call the method i.e. if value of integer x is 2,
call Sample2().
A string variable needs to print the next letter in the alphabet in place of the first character in the defined
string.
You have already defined two interfaces as shown alongside. If you need to implement a third interface that
can accept the instances of these two interfaces.
A string array "sampleArray" containing some null elements is given. Which of these code snippets can be
used to remove these null values from the array?
You are given the code snippet shown alongside. If you want to print all Client names along with their
clientids, which of these choices would you need to append to the code.
Also, identify the type of functional interface being implemented in the given scenario?
Which of the following class declarations can be used to represent aggregation in java?
You are assigned a number of tasks while working with threads in java. Two of the tasks assigned are high
priority while the rest of the tasks have normal priority.
Which of the following scheduling methods would be used by the Java thread scheduler in this situation?
You are given the Java class shown alongside. What would happen if you run the Java statement given
below?
You want to create a method that would be used to convert an 'optional' object to a stream. Which of the
following statements would most likely form a part of this function?
(Assume that myopt is the optional object that has been sent as argument.)
Which of the following classes are not instantiable in java if reflections cannot be used?
An object in a swing application extends an AccessibleContext class. If a property bound to the object is
modified which of the following behaviour can be expected?
You are collecting a list of employee names from an employee database using the StringBuilder class.
If you pass a null argument to a method in this class while doing the above operation, which of these
exceptions are you likely to encounter?
You are writing a class that inherits itself in java, when it results in a overflow crash. If the code alongside is
given to you which of the following code snippets can be used to achieve this?
Which of these code snippets can be used to do so by overriding the equal method in java?
You have a string defined and you wish to modify this string by adding a special character(#) before and
after every character in the string. Which of the following code snippets can be used to do so?
(Assume that if the input is sample ,the corresponding output will be #s#a#m#p#l#e#)
You are provided the code shown alongsside. Which of the following code snippets can be used to make
sampleList immutable?
You need to obtain the string shown alongside using string formatter. Which of the following commands can
be used to produce the required output using string.format()?
You have a class named Sample which is extended by Sample1 and Sample2.
Which of these code snippets can be used to determine if a given object of class Sample is of type
Sample1 or Sample2?
You wish to read a file using java. However, before reading the file you need to check whether the file is
present. Which of the following code snippets can be used to do so?
A Set interface with only one operation, and one simple implementation class is given alongside. The class
Universe is unable to correctly implement the Set interface. Identify the correct reason for this behavior.
Predict the output of the program given alongside and choose the appropriate option.
Consider the code snippet given alongside.If a function "printArray()" is called to print the values. Which of
the following can be considered as the valid function definition?
R : Strings are interned in Java. Hence, the literal string "LOCK" turns out to be the same instance of
java.lang.String even though they are declared completely disparately from each other.
Consider the code snippet given alongside. Which of these are likely to be the value of sl when the snippet
is run?
Which of the following options can be used to define monitors for various objects for thread synchronization
in a multithreaded process in Java?
You have been asked to create a Java class that has two initialization blocks and one constructor. Which of
the following options would you follow to define the class correctly?
An Intrinsic lock is utilised to establish which of the following relationships between resources in order to
maintain visibility in a Java 8 Environment ?
You are provided with the code given alongside to implement a Reentrant Lock in a Multithreaded
environment designed for Java 8.
Which of the following alternatives can be utilized while requesting access to the lock to check for access
without affecting the current thread execution?
You want to find the length of the longest line within a file using the code snipppet given alongside.
Which of these code snippets can be utilized to perform the same operations using streams in a more
optimal manner?
While troubleshooting an error, you need to read all the files from a particular folder.
While running the code snippet shown alongside, you find a typemismatch error.
Which of these values need to be assigned in place of X in order to prevent this error?
What would be the output of the code snippet when executed using the main function.
Main Function:
class TestThread {
public static void main(String args[]) {
threadDemo T1 = new threadDemo( ""T 1"");
T1.start();
threadDemo T2 = new threadDemo( ""T 2"");
T2.start();
}
}
Code Snippet:
public interface SampleA { public <T instance of public <T extends SampleA
void First(); SampleA & SampleB> void & SampleB> void
} FirstAndSecond(T x) { FirstAndSecond(T x) {
x.First(); x.First();
public inteface SampleB { x.Second(); x.Second();
void Second(); } }
}
sampleArray = sampleArray
sampleArray = .filter(s => (s !=
Arrays.stream(sampleArray) null && s.length() > 0))
.filter(s -> (s !=
null && s.length() > 0)) .toArray(String[]::new);
.toArray(String[]::new);
class Child implements Parent Thread c = new Thread(); Child run = new Child();
{ p.run(); Thread c = new
public static void main(String args[ ]) Thread(run);
{ c.start();
}
public void run() { }
}
class A{ class A{
} }
class B{ class B extends A{
A obj; }
}
myoptj.isPresent() ? myopt.isPresent() ?
Stream.of(myopt.get()) : Stream.of(myopt.get()) :
Stream.close(); Stream.empty();
class Main {
public
public static
static void
void main(String[]
main(String args)
args[]) { { static void printArray( E[] arr static < E > void
Class1 b = new Class2();;
Integer[] a = { 1, 2, 3, 4, 5 }; ){ printArray( E[] arr ) {
b.show();
Double[] b = { 1.1, 2.2, 3.3, 4.4 }; for(int i=0; i<arr.length; i++){ for(E element : arr) {
} Character[] c = { 'H', 'E', 'L', 'L', 'O' }; System.out.print(arr[i]+" "); System.out.printf("%s ",
} printArray(a); } element);
printArray(b); } }
printArray(c); }
}
this.s1 = s1 this.s1 = s1
this.s2 = s2 this.s2 = s2
} }
} }
private static final String LOCK = "LOCK"; R is the correct reason and R is the correct reason but
public dummy_module() { S is a correct Workaround S is not a correct
synchronized(LOCK) { Workaround
this.work();
}
}
} }
happens-with happens-before
long= l.get(i);
if (i < l.length() - 1)
long = findMaxStringLine(longest,
l,i +1);
if (longest.length() > l.get(i).length())
return long;
return l.get(i);
}
try (Stream<Paths> paths = try (Stream<Path> paths =
Files.walk(Paths.get("/samp Files.walk(Paths.get("/samp
le/SampleFolder"))) { le/SampleFolder"))) {
paths paths
.filter(Files::isRegularFile) .filter(Files::isRegularFile)
.forEach(System.out::println .forEach(System.out::println
); );
} }
String List<Future<String>>
X futures =
executorService.invokeAll(callableTasks);
0 T 2, 2
T 1, 2
T 2, 1
T 1, 1
Answer Choice 3 Answer Choice 4 Answer Choice 5 Correct answer
(optional)
public class A{ Both Choice 1 and Choice 2 Both Choice 1 and choice 3 Choice 5
public int x;
private A() {
this.x = 2;
}
}
static < E > void static < class E > void Choice 2
printArray( E[] arr ) { printArray( E[] arr ) {
for(element : arr) { for(E element : arr) {
System.out.printf("%s ", System.out.printf("%s ",
element); element);
} }
} }
this.s1 = s1 this.s1 = s1
this.s2 = s2 this.s2 = s2
} }
} }
R is the incorrect reason but R is the incorrect Reason Choice 1
S is the correct Workaround and S is the incorrect
Workaround
executing... Choice 4
executing... executing...
executing... false
.filter(Files::isRegularFile) .filter(Files::isRegularFile)
.forEach(System.out::println .forEach(System.out::println
); );
} }
usage of getDeclared
NA
NA https://docs.google.com/spreadsheets/d/1XcJYJeVU-gL4g3R_jaRLcqhxjs84PgR_Pp-foSBANTI/ed
NA
Java implicitly creates a
constructor when no
constructor is defined in a
class.
By design https://www.google.co.in/url?sa=t&rct=j&q=&esrc=s&source=web&cd=2&cad=rja&uact=8&ved=0a
pg 1184 https://www.csie.ntu.edu.tw/~r93020/eBook/OReilly.Java.Swing.2nd.2002.pdf
NA https://docs.oracle.com/javase/8/docs/api/java/lang/StringBuilder.html
seperate conditions on
instances of both classes.
Checks for first instance
equals to first object and
likewise
NA
Na
NA
NA
NA
Choice 1: https://docs.oracle.com/javase/tutorial/java/IandI/usinginterface.html
Universe.contains does
satisfy the spec of
Set.contains
Choice 2: Universe is not
mutable. It has no mutator
Choice 3: Universe does
not declare that it
implements Set<E>, so
that would indeed keep it
from implementing the
interface correctly.
Choice 4: Universe
doesn't need to
when methods point
are to
static
every possible object.
runtime polymorphism does It
already
not work does what its
spec promises, without
knowing about any of the
actual objects in E.
NA
NA
NA
NA https://docs.oracle.com/javase/tutorial/essential/concurrency/locksync.html
NA http://winterbe.com/posts/2015/04/30/java8-concurrency-tutorial-synchronized-locks-examples/
By design http://www.baeldung.com/java-executor-service-tutorial
NA