0% found this document useful (0 votes)
2 views2 pages

Java Interview questions

The document discusses various concepts in Java, including multiple inheritance, memory management (stack vs heap), and the advantages of Java over C++. It covers topics such as singleton classes, string manipulation, and the collections framework, highlighting their functionalities and limitations. Additionally, it mentions the Spring framework and its extension, Spring Boot, for building Java applications.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views2 pages

Java Interview questions

The document discusses various concepts in Java, including multiple inheritance, memory management (stack vs heap), and the advantages of Java over C++. It covers topics such as singleton classes, string manipulation, and the collections framework, highlighting their functionalities and limitations. Additionally, it mentions the Spring framework and its extension, Spring Boot, for building Java applications.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

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),

You might also like