NIIT Technologies Java Interview Questions

NIIT Technologies Java Interview Questions
Download NIIT Technologies Java Interview Questions PDF

Below are the list of Best NIIT Technologies Java Interview Questions and Answers

In the year 2005, SQL server has introduced apply operator. This is basically a joining that shows the expression of the left table with the right table expression. The expressions that are basically produced in the right table expression is after following up each row in the left table. The left table expressions are calculated in the first hand and then the right table. After following this process we can get our final set value.

Spring MVC is a framework of Java used for developing web applications. It follows the design pattern of Model-View-Controller. A spring MVC gives an optimum solution to use the spring framework along with MVC. To do so, it takes the help of the DispatcherServlet that receives the incoming request and then implements it to a suitable resource including controllers, views, and models. Spring MVC has a number of advantages such as rapid development and ease of testing.

Abstraction is basically used to separate the useless data from the essential ones. Only the important things that need to be shown to the users are only being exposed. Here in these issues, the users get to view only the essential data which is actually required. It also helps in differentiating the object from any other similar object just by looking into the classification of features. It is a really efficient process of filtering.

The difference between the left and right outer join is as follows:

S. N.Left JoinOuter Join
1A left outer join provides the table in the FROM clause whose all rows are returned.A right outer join allows for returning all rows from the table specified in the join clause.
2A left outer join fetches the unmatched rows from the table which is on the left of the join clause.A Right outer join fetches the unmatched rows from the table which is on the right of the join clause.

HashMap in Java works on hashing principles. Hashing is a process in which hash functions are used to link key and value in HashMap.

A factorial program using recursion in JAVA is as follows:

class FactorialExample2{  
 static int factorial(int n){    
  if (n == 0)    
    return 1;    
    return(n * factorial(n-1));    
 public static void main(String args[]){  
  int i,fact=1;  
  int number=4;//It is the number to calculate factorial    
  fact = factorial(number);   
  System.out.println("Factorial of "+number+" is: "+fact);    

Operator overloading allows doing something extra than what it is expected for. Java only allows arithmetic operations. Operator overloading allows multiple meanings for the same operator which will make things more confusing and messy.

Java doesn't support operator overloading due to its simplicity. Every operator has a specific meaning with its arithmetic operation it performs.

    Several ways to avoid memory leaks in Java are as follows:
  1. Release the session when it is no longer needed. Use the HttpSession.invalidate() to do this.
  2. Keep the time-out time low for each session.
  3. Store only the necessary data in your HttpSession.
  4. Avoid using string concatenation. Use StringBuffer’s append() method because the string is an unchangeable object while string concatenation creates a lot of unnecessary objects. A large number of temporary objects will slow down performance.
  5. As much as possible, you should not create HttpSession on your JSP page. You can do this by using the page directive <%@page session=” false”%>.
  6. If you are writing a query that is frequently executed, use the PreparedStatement object rather than using the Statement object. Why? PreparedStatement is precompiled while Statement is compiled every time your SQL statement is transmitted to the database.
  7. When using JDBC code, avoid using “*” when you write your query. Try to use the corresponding column name instead.
  8. If you are going to use stmt = con.prepareStatement(SQL query) within a loop, then be sure to close it inside that particular loop.
  9. Be sure to close the Statement and ResultSet when you need to reuse these.
  10. Close the ResultSet, Connection, PreparedStatement, and Statement in the finally block.

EnumSet is basically used for coding purposes. Where there are a set of words that have the same meaning and can be denoted by a single word. Like for example, there are a set of words that consists of words like red, green, yellow, blue. These all words can be denoted by a single word which can be easily denoted by a single word like Colours. It is basically of high performance and is really reliable.

    To create a synchronized collection from a given collection follow detailed Steps:
  • Step 1: Create an ArrayList
  • Step 2: Populate the ArrayList with elements, with add(E e) API method of ArrayList
  • Step 3: Invoke the synchronized list(List list) API method of Collections to get the synchronized list from the provided ArrayList

Ceil and Floor are the functions of Oracle and both of them are completely opposite to each other.

  • Oracle CEIL function: This function is used to return the smallest value of integer to the greater or equal value of the supplied number. In short, it rounds up the digit to the nearest whole number. Ceil is the short form used for the ceiling.
  • Oracle FLOOR function: This function of Oracle is used to round down the value to the nearest whole number. The main purpose of using floor function is to return the value of the highest integer to the greater or equal of the lowest value of the supplied number.

Singleton design pattern is a creational pattern that is used whenever only one instance an object is needed to be created. In this pattern, you can't initialize the class.

The differences between The hashCode() method and The equals() method are as follows:

The hashCode() methodThe equals() method
The hashCode() method The hashCode() method returns an integer value, which is referred to as the hash code value of an object. Every Object, at the time of creation assigned with a unique 32-bit, signed int value. This value is the hash code value of that object. The hashCode() method should return the same integer value for the same object for each calling of this method unless the value stored in the object is modified. If two objects are equal(according to equals() method) then the hashCode() method should return the same integer value for both the objects. But, it is not necessary that the hashCode() method will return the distinct result for the objects that are not equal (according to equals() method).The equals() method The equals() method of Object class checks the equality of the objects and accordingly it returns true or false. The default implementation, as provided by the Object class, checks the equality of the objects on the basis if both references refer to the same object. It does not check the value or state of the objects. But we can override this method to provide our own implementation to compare the state or value of the objects. For any non-null reference variables a, b and c a.equals(a) should always return true. a.equals(b) should return true if and only if b.equals(a) returns true. If a.equals(b) returns true and b.equals(c) returns true then a.equals(c) should return true. Multiple calling of a.equals(b) should consistently return true or consistently return false If the value of the object is not modified for either object. a.equals(null) should return false.

Dependency injection is way to pass one obeject dependencies to another object.It is a broader form of inversion of control (IOC).

There are basically 3 types of dependency injection:

  • constructor injection
  • setter injection
  • Interface injection

Click Here to Read More 100 Questions on Laravel 5 & 6

The differences between String buffer and String builder are as follows:

1)StringBuffer is synchronized.StringBuilder is non-synchronized.
1)StringBuffer is thread-safe.StringBuilder is not thread-safe.
1)Two threads can't call the methods of StringBuffer simultaneously.Two threads can call the methods of StringBuilder simultaneously.
2)StringBuffer is less accomplished than StringBuilder.StringBuilder is more accomplished than StringBuffer.

The four pillars of the OOPs are:

  • Abstraction: Abstraction is basically used to separate unwanted things from the essential ones. Only important properties.
  • Encapsulation: The encapsulation process consists of certain methods and properties of the abstraction process. It also protects these methods from any interference or tampering.
  • Inheritance: Inheritance is of two types basically: single inheritance & multiple inheritances. It is how a class is derived from the other class.
  • Polymorphism: Here in polymorphism, you can name it all the same for the different actions of an object of different data types.

The abstract function or method does not have a body and also it cannot be implemented. The abstract classes cannot be started without the help of the subclasses that help in providing the implementations which are actually for the abstract methods. They actually try developing base classes which help in the custom implementation. The keyword abstract can be used to denote both the abstract methods and also an abstract class.

JFrame, Swing's top-level container provides a window on the screen and frame is a support window where additional components depend, like the menu bar, panel, label, text field, button, etc. Nearly every Swing application commences with a JFrame window. The javax.swing.JFrame class is a container that inherits the java.awt.Frame class. Moreover, JFrame operates like the main window where elements like label, button, text field are combined to create a GUI. Unlike Frame, JFrame has the choice to hide or terminate the window with the help of setDefaultCloseOperation(int) function.