Capgemini Java interview questions

  1. Outline the major features of Java.
  2. Write a program to check for a prime number in Java?
  3. Explain What is Spring MVC?
  4. What are Mutable classes?
  5. Write a java program for binary search?
  6. What are structs in java?
  7. Explain the difference between call by refrence and call by value?
  8. Write an sql query for deleting duplicate rows ?
  9. What is hashing in Java?
  10. Write a program to find the greatest of three numbers in Java?
  11. What is JVM? How its run?
  12. What is a cursor, index in SQL ?
  13. Write code to implement bubble sort in Java?
  14. What are design patterns and please explain?
Capgemini Java interview questions
Download Capgemini Java interview questions PDF

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

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.in);
  System.out.print("Enter any number: ");
  // This method reads the number provided using keyboard
  int num = scan.nextInt();
  // Closing Scanner after the use
  scan.close();
  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;
     break;
    }
   }
   if (flag == 0) {
    System.out.println(num + " is prime number");
   }
  } //end of else
 }
}