Java Interview Questions asked in Citibank

Java Interview Questions asked in Citibank
Download Java Interview Questions asked in Citibank PDF

Below are the list of Best Java Interview Questions asked in Citibank and Answers

    

It is a process in java through which multiple threads can be executed simultaneously. A thread can be explained as a lightweight sub-process, it is the smallest unit of processing. Both multiprocessing and multithreading are done to achieve multitasking in java. The reason why most of the developers use multithreading over multiprocessing is that the threads use a shared memory area. Because they don’t allocate a separate area in the memory and they save a lot of space in the memory because of that.

Differences between overloading and overriding

OverloadingOverriding
Overloading is performed at compilation time.Overriding is performed at runtime
Overloading is also called static binding.Overriding is also called dynamic binding.
Overloading is done within the class.Overriding occurs in between two classes that have an IS-A (inheritance) relationship.
It is an example of compile-time polymorphism.It is an example of run time polymorphism.

Overloading Example:

class ExampleClass{  
static int sum(int a,int b){return a+b;}  
static int sum(int a,int b,int c){return a+b+c;}  
}  

Overriding Example:

class Animal{  
	void eat(){System.out.println("eating...");}  
}  
class Dog extends Animal{  
	  void eat(){System.out.println("eating bread...");}  
}   

The Transient variable is a modifier that is used in the process of serialization. If the developer doesn’t want to store the value of a particular variable in a file at the time of serialization then they use the Transient keyword. JVM ignores the original value of the variable and saves the default value of that variable data type when it comes across the Transient keyword. It also plays an important role to meet security constraints.

Executor Design pattern can be defined as a particular type of design pattern that serves the purpose of decoupling the execution of a task from the real task taken by the user with the help of executors. Executors are specially designed to provide factory methods. These methods can be further used in the creation of ThreadPools of worker threads. It decouples the submission of a command from the execution of that very command.

Difference between HashSet and HashMap are given below:

HashSetHashMap
The set interface is implemented by the HashSet class.The map interface is implemented by the HashMap class.
Objects like elements or values are stored inside the HashSet. For example, if there is HashSet of string elements then it can portray a set of HashSet elements.Key and value pairs are stored in HashMap. In other words, the mapping of Key and value is maintained by HashMap.
Duplicate elements are not allowed in HashSet, i.e., no duplicate values can be stored in it.Duplicate Key is not allowed in HashMap, but duplicate values can be stored.

The externalizable interface is a special type of interface that enables the user to define personalized rules and mechanisms for the purpose of serialization. Users can create their own contracts as well as protocols for serialization. This gives the power of deciding what to store and what not to store in the stream. Here, the user has to mention what they can put in the program as fields and variables explicitly.

                  

                 

Autoboxing is the automatic conversion that the Java compiler makes between the primitive types and their corresponding object wrapper classes. For example, converting an int to an Integer, a double to a Double, and so on. If the conversion goes the other way, this is called unboxing.

Here is the simplest example of autoboxing:

Character ch = 'a';

There are mainly three types of database indexes, they are:

  • Clustered Indexing
  • Non-Clustered or Secondary Indexing
  • Multilevel Indexing