Java Oops : Does Java support multiple inheritance?
Difference between Stack memory and heap memory, why do we need two memories?
How Java is better than C++? It is platform independent?
Doctor and patient appointments: System Design
Circular LinkedList – use case
String : collection of characters,
String pool – separate memory in heap, (all similar values are not recreated in pool) – makes our
memory optimized.
Singleton class: one instance of a class exists
Private constructor – so that no instance can initialize
Static Instance Variable: static and private
Public Static Factory Method (getInstance()): In this method instance is created if(instance == null)
instance = new Singleton();
Return instance;
Immutablity:
‘a’ + ‘b’ => if two char is added gives sum of ascii values 195, if a char+ string gives a string (string
concatination)
stringBuilder: data type where strings can be modified without creating a new string.
Comparison of strings: (==) comparator checks if reference variables are pointing to same object.
a.equals(b) => only checks for values.
Find if a goal string is present in the rotated string S;
Java code :
return (s+s).contains(goal);
C++ code: return ((s+s).find(goal) != string::npos)
Substring in java => str.substring(“startIndex”,”endIndex”);
Substring in java => str.substr(“startIndex”,”endIndex”);
Size() vs length vs length():
Arrays , string arrays : int [], String[] – length;
String s = “”, length()
Collections – size()
Collections Framework:
Array drawbacks – fixed size, Homogeneous data, arrays can hold primitives and objects
Collection drawbacks – performance is low, can hold objects.
Collection has default capacity of 10 elements, if it exceeds a default capacity a bigger ArrayList is
created internally.,
Collection is representing a group of objects as a single entity (like add, remove, isEmpty)
Collections are combination of utility classes (like sort, searching)
Spring : It is a Java framework , spring boot : extension of spring, provides different starter template
(contains all dependencies),