Post on 21-Apr-2017
How do you run a Java application on the command line and set the classpath with multiple jars?
Question 2:
What i s the d i f fe rence be tween a ClassNotFoundException a n d NoClassDefFoundError?
Question 5:
Given two double values d1, d2, why isn’t it reliable to test their equality using:
Question 7:
d1 == d2
final double d = 1 / 2;
System.out.println(d);
Question 10:Why does
Print 0? How can you make the code print 0.5 instead?
IntStream.range(0, 10).forEach(System.out::println);
Question 11:In this code:
what is the inferred type of the method reference System.out::println?
final Path path = Paths.get(...);
Files.lines(path).forEach(System.out::println);
Question 12:What is the problem with this code:
What will be the contents of the list after this operation and why?
Question 13:
final List<Integer> list = new ArrayList<>();
list.add(1);list.add(2);list.add(3);
list.remove(2);
Identify the problem in the following code:Question 19:
public class Foo { public Foo() { doSomething(); }
public void doSomething() { System.out.println("do something acceptable"); }}
public class Bar extends Foo { public void doSomething() { System.out.println("yolo"); Zoom zoom = new Zoom(this); }}
Why aren’t you allowed to extend more than one class in Java but are allowed to implement multiple interfaces?
Question 30:
Question 31:
Test t = null; t.someMethod();
public static void someMethod() { ... }
Why doesn’t the following code generate a NullPointerException even when the instance is null?
Question 32:public class Test{ public static void main(String[] args) { Integer a = 1000, b = 1000; System.out.println(a == b);
Integer c = 100, d = 100; System.out.println(c == d); }}
why does the first case print false while the second case prints true?
Question 33:
String s1="home"; String s2="mohe";
How do you check whether or not the following two strings are anagrams?
Did you know how to answer all 37 questions?
Feel free to check your answers hereor
schedule a mock interview withan experienced Java developer