0% found this document useful (0 votes)
119 views

Java Interview HSBC

Uploaded by

Utsav Galphat
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
119 views

Java Interview HSBC

Uploaded by

Utsav Galphat
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 3

spring data or JPA

how to create a custom repository


what is an entity and how to create one
spring-security : OAuth [auth vs autherization]
Types of spring transactions and various use cases and types of rollback
Does Microservice uses a common database
Kafka: topic and queue have you worked on any messaging/queue
App versioning :
saga pattern
cqrs pattern
Source tool using -- git
what is a cookie? where the cookie is stored
put vs post :
PathParam vs RequestParam
java profiler
Optimising garbage collector

deadlock: how to know


Ways to implement thread

junit : junit framework : mockito end to end integration testing


logging framework : log4j how to configure SLF4j
start logging debug mode: debug printed
what is a root logger
oops concepts
Solid principles
what is polymorphism
static and instance method
Why String is immutable
What is the practical use of immutable objects?
Stack & heap memory
What is the need for StringPool
String.intern();
1.8 string deduplication
Immutability in java
final class C{
private String a;
private int b;

public C(String a, int b){


this.a = a;
this.b = b;
}
//getters
}
Implement custom exceptions
class myExc extends Exceptions(){

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(){

synchronised public static A createInstance(){

}
}
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

MyANS:select d.dept, sum(salary) from Employee e


right join Department d on e.deptId = :id groupBy e.deptID;
/**
* Finds the first character that does not repeat anywhere in the input string
* Given "apple", the answer is "a"
* Given "racecars", the answer is "e"
**/

class MyCode {
public static void method(String s){
s= null;
}

public static void main (String[] args) {


String s = "pple $%";
method(s);
Syso(s);
Map<Character,Integer> map = new LinkedHashMap<>();
for(char c : s.toCharArray()){
if((int)c != 32){
map.put(c, map.getOrDefault(c, 0) + 1);
}
}
for(char c : map.keySet()){
if(map.get(c).equals(1)){
System.out.println(c);
break;
}
}
System.out.println("No character occur once");
}

You might also like