Capgemini Java interview questions

Capgemini Java interview questions
Download Capgemini Java interview questions PDF

Below are the list of Best Capgemini Java interview questions and Answers

In SQL, a cursor can be defined as a tool used widely to define a particular set of results. This result can be a set of data rows. A cursor is basically used to solve complex logic and works on a row by row manner.

Index, on the other hand, has the main function of retrieving data from tables much quicker. Indexes are created by users on columns that may be accessed frequently. This enables the user to get information quickly from the table and can be created on a single column or even a group.

The major features of Java are listed below: –

  • Object-oriented: – Java language is based on object-oriented programming. In this, the class and the methods describe the state and behavior of an object. The programming is done by relating a problem with the real world object.
  • Portable: – the conversion of java program into Java bytecodes take place. This helps in running the program in any environment or platform without any dependency.
  • Platform independent: – java ensures “write once run anywhere” as its programs can be run on multiple platforms like- Windows, Mac, Sun Solaris, Linux, etc.
  • Robust: – java’s strong memory due to no pointer allocations, make it robust. The memory leaks are prohibited with the help of automatic garbage collection in java.
  • Interpreted: – the java code is converted into bytecodes by the java compiler which is then interpreted and executed by the Java interpreter or a just-in-time compiler (JIT).

In SQL, normalization of data is a process through with data is organized in tables used for the reduction of redundancy and dependency of data. It divides large tables into smaller ones using some set of rules.

Types of normalization:

  • 1NF: The rules of 1NF are that each table must contain a single value and records are required to be unique.
  • 2NF: The rules of 2NF are that the table must be in 1NF and must possess a single-column primary key.
  • 3NF: The rules of 3NF are that the table must be in 2NF and must not have any transitive functional dependencies.
  • BCNF: The rules of the Boyce Codd Normal form is that it must be in 3 NF and must not have more than one candidate key.

Difference between Class and object In JAVA:

  • Class - A class is like a blueprint. It is the class with the help of which objects are created. The class holds together data and methods in one single unit. And the class needs to be declared only a single time.
  • Object - This is an instance of the class. It is with the help of an object that data and methods that exist within a class can be used. Objects can be called upon several times as and when required.

Inversion of control is a design pattern that is used for decoupling components and layers of a system. Inversion of control(IOC) is implemented through injecting dependencies into a component when it is constructed.

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.

Design patterns can be explained as a general repeatable solution to a problem that is occurring commonly in large numbers during the designing of the software. Design patterns are not considered as a finished design and cannot be directly converted into code. It can be defined as a description or a template that depicts how to solve a problem that is occurring in different situations. It speeds up the development process.

Following code implements bubble sort in JAVA:

// Java program for implementation of Bubble Sort
class BubbleSort
    void bubbleSort(int arr[])
        int n = arr.length;
        for (int i = 0; i < n-1; i++)
            for (int j = 0; j < n-i-1; j++)
                if (arr[j] > arr[j+1])
                    // swap temp and arr[i]
                    int temp = arr[j];
                    arr[j] = arr[j+1];
                    arr[j+1] = temp;
    /* Prints the array */
    void printArray(int arr[])
        int n = arr.length;
        for (int i=0; i<n; ++i)
            System.out.print(arr[i] + " ");
    // Driver method to test above
    public static void main(String args[])
        BubbleSort ob = new BubbleSort();
        int arr[] = {64, 34, 25, 12, 22, 11, 90};
        System.out.println("Sorted array");

JVM stands for Java Virtual Machine. JVM can be explained as an engine that is used by the Java Development Kit to provide a runtime environment to run java code or its applications. The main function of JVM is that it is used for converting Java bytecode into machine language. It is an integral part of the Java Runtime Environment. It works on “Write once, run anywhere” principle and manages the program memory.

A number that is divisible by 1 or itself is a Prime Number. 2, 3, 5, 7, 11, 13, 17 are examples of some Prime numbers.

Please Note: 0 and 1 are not a prime number.

Below is a simple Prime number Program in Java to check a number is Prime or Not.

import java.util.Scanner;
public class PrimeExample {
 public static void main(String args[]) {
  int i, m = 0, flag = 0;
  Scanner scan = new Scanner(;
  System.out.print("Enter any number: ");
  // This method reads the number provided using keyboard
  int num = scan.nextInt();
  // Closing Scanner after the use
  m = num / 2;
  if (num == 0 || num == 1) {
   System.out.println(num + " is not prime number");
  } else {
   for (i = 2; i <= m; i++) {
    if (num % i == 0) {
     System.out.println(num + " is not prime number");
     flag = 1;
   if (flag == 0) {
    System.out.println(num + " is prime number");
  } //end of else

A program to find the greatest among three numbers is as follows:

public class JavaExample{

  public static void main(String[] args) {

      int num1 = 10, num2 = 20, num3 = 7;

      if( num1 >= num2 && num1 >= num3)
          System.out.println(num1+" is the largest Number");

      else if (num2 >= num1 && num2 >= num3)
          System.out.println(num2+" is the largest Number");

          System.out.println(num3+" is the largest Number");

Hashing is the process of converting a given key to another value by using a hash function that is used to generate the new value according to a mathematical algorithm. The result of a hash function is known as a hash value(hash code) or simply, a hash. Hashing refers to the way that uses some function or algorithm to map object data to some representative integer value. It can be used as a way to narrow down our search when looking for the item on the map.

The difference between call by reference and call by value

ParametersCall by valueCall by reference
DefinitionWhile calling a function, when you pass values by copying variables, it is known as "Call By Values."While calling a function, in programming language instead of copying the values of variables, the address of the variables is used it is known as "Call By References.
ArgumentsA copy of the variable is passed in this method.A variable itself is passed in this method.
Alteration of valueIt does not allow you to make any changes in the actual variables.It allows you to make changes in the values of variables by using function calls.
EffectChanges made in a copy of the variable never modify the value of the variable outside the function.Change in the variable also affects the value of the variable outside the function.
Alteration of valueIt does not allow you to make any changes in the actual variables.It allows you to make changes in the values of variables by using function calls.
Passing of variableValues of variables are passed using a straightforward method.Pointer variables are required to store the address of variables.
Value modificationOriginal value not modified.The original value is modified.
Memory LocationActual and formal arguments will be created in different memory locationActual and formal arguments will be created in the same memory location
SafetyActual arguments remain safe as they cannot be modified accidentally.Actual arguments are not Safe. They can be accidentally modified, so you need to handle arguments operations carefully.

Structs is a framework in Java. The use of this framework is for the development of the Java enterprise edition purpose. It is an open-source framework. This is a very reliable and efficient working framework. In order to introduce the MVC which is known as the model view controller, it makes use of the Java servlet API and also it extends its functions for more results. It later became one of the best frameworks that were designed in the Apache project.

A JAVA program uses the Binary search algorithm to search an element in the given list of elements is as follows:

import java.util.Scanner;
class BinarySearchExample
   public static void main(String args[])
      int counter, num, item, array[], first, last, middle;
      //To capture user input
      Scanner input = new Scanner(;
      System.out.println("Enter the number of elements:");
      num = input.nextInt(); 

      //Creating array to store the all the numbers
      array = new int[num];

      System.out.println("Enter " + num + " integers");
      //Loop to store each numbers in array
      for (counter = 0; counter < num; counter++)
          array[counter] = input.nextInt();

      System.out.println("Enter the search value:");
      item = input.nextInt();
      first = 0;
      last = num - 1;
      middle = (first + last)/2;

      while( first <= last )
         if ( array[middle] < item )
           first = middle + 1;
         else if ( array[middle] == item )
           System.out.println(item + " found at location " + (middle + 1) + ".");
             last = middle - 1;
         middle = (first + last)/2;
      if ( first > last )
          System.out.println(item + " is not found.\n");
Output 1:

Enter the number of elements:
Enter 7 integers
Enter the search value:
77 found at location 4.

Mutable classes are the classes that are being prepared can change its internal state anytime without any issue. Also, it can change the state even after it has been already developed. The classes here are not the ones that are actually mutable. But the object that consists inside it, they are actually the mutated ones. Until we can prevent it from any change after it has been developed. It also depends strongly on the language that is being used.

An applet is a Java application that could be installed into a web page and runs within the web browser and operates at the client-side. It is usually embedded in an HTML page using the APPLET or OBJECT tag and treated on a web server.

Applets are employed to make the web site more productive and entertaining. All applets are sub-classes (directly or indirectly) of java.applet. Applet class and are not stand-alone applications. Instead, they work in a web browser or an applet viewer. JDK provides a standard applet viewing tool known as applet viewer. In general, the working of an applet does not begin at the main() method. When an applet starts, the init(), start() and paint() methods are called in a sequence and when an applet is terminated, stop( )and destroy( ) method calls take place.

JFreeChart is a java chart library that helps developers to show good and quality charts in the applications they developed. It is open-source software that is distributed under the conditions of GNU Lesser General Public Licence. Jfreechart is totally free and it is made up of different features. Some of the extensive features of Jfreechart are:

  • A well written and constant API that supports a large number of chart types.
  • The design is flexible and extending it is easy. It targets client and server-side applications.
  • JavaFX and Swing components, vector graphics file formats such as SVG, PDF, image files such as JPEG and PNG are some of the output types it supports.

Daemon thread is a low need string (in setting of JVM) that runs in foundation to perform assignments, for example, trash assortment (GC) and so forth., they don't keep the JVM from leaving (regardless of whether the daemon string itself is running) when all the client strings (non-daemon strings) finish their execution. JVM ends itself when all client strings (non-daemon strings) finish their execution, JVM couldn't care less whether Daemon string is running or not, if JVM discovers running daemon (endless supply of client strings), it ends the string and after that shutdown itself.