Java Interview HSBC
Java Interview HSBC
String msg ;
myExc(string s){
supper(s);
}
}
Inheritance
class A{
method(String s) {
}
}
class B extends A{
method(String s) throws RuntimeException {
Overloading rules
Creational design patterns such as singleton, prototype, Factory, etc.
Singleton implementation
strategy pattern
Java inbuilt class which uses Factory pattern
Java inbuilt class which uses the singleton pattern
Generics - static compilation check
Volatile keyword
Join method
difference between wait and yield
notify vs notifyAll
Thread safe singleton implementation
class A{
public static A a ;
private A(){
}
}
Synchronization
Executor framework
core size and max size in the executor
SingelThreadPoolExecutor
submit() method in Executor service
How to catch exception in a thread
ExecutionException
Java 8 features
Futures
Future.get(); // blocking or not
lambda expressions
Optional.ofNullable()
streams
intermediate vs terminal
lazy initialization
streams
Collection
Collection.sort -- how it can sort on custom sorters
ArrayList vs LinkedList
Hashmap collisions
EMP emp1 = new EMP(“1”,”aa”);
EMP emp2 = new EMP(“2”,”bb”);
Map<EMP, String> map = new TreeMap();
map.put(emp1,”Emp1”);
map.put(emp2,”Emp2”)
EMP emp3 = new EMP(“1”,”aa”);
System.out.println(map.get(emp3));
Comparable vs comparator
hashmap internal working
Treemap internal working
//Employee -> id, name, salary, deptId
//Department -> id, name
// total salary from each dept.
//resultset -> dept name and total salary
class MyCode {
public static void method(String s){
s= null;
}