CTS Java Interview Questions (Complete Set)
1. Core Java & OOPs Concepts
1. What are the basic data types in Java?
2. What is the difference between primitive and non-primitive data types?
3. What is a class and an object in Java?
4. Explain OOPs concepts: Inheritance, Polymorphism, Encapsulation, and Abstraction.
5. What is the use of the `this` keyword in Java?
6. What is the purpose of a constructor? How is it different from a method?
7. What is the difference between method overloading and overriding?
8. What are access modifiers in Java?
2. Control Flow & Basics
1. Explain if-else and switch-case statements.
2. What are the different types of loops in Java (for, while, do-while)?
3. Difference between break and continue.
4. How is the main() method written and why is it public static void main(String[] args)?
3. String Handling
1. What is the difference between String, StringBuilder, and StringBuffer?
2. How do you compare two strings in Java?
3. What is immutability in strings?
4. Write a program to reverse a string.
5. Write a program to count vowels in a string.
6. Write a method to check if two strings are anagrams.
4. Arrays & Collections
1. How do you declare and use arrays in Java?
2. What is the difference between ArrayList and LinkedList?
3. What are the key differences between List, Set, and Map?
4. What is a HashMap and how does it work internally?
5. Difference between HashSet and TreeSet?
CTS Java Interview Questions (Complete Set)
5. Exception Handling
1. What is the difference between Exception and Error?
2. What are checked and unchecked exceptions?
3. How do you use try, catch, finally, and throw?
6. Multithreading
1. What is multithreading in Java?
2. Difference between Thread class and Runnable interface?
3. What are synchronized blocks?
7. JDBC & Web Basics
1. How do you connect Java to a database using JDBC?
2. What is the difference between GET and POST methods in web development?
3. What is a Servlet? Explain its life cycle.
8. Java 8 Features
1. What is a lambda expression?
2. What is a Functional Interface?
3. Explain the Stream API in Java 8.
9. Coding Questions
1. Write a program to find factorial using recursion.
2. Write a program to check if a number is prime.
3. Write a Java function to remove duplicates from an array.
4. Write a Java program to print Fibonacci series.
5. Write a SQL query to fetch the second highest salary from a table.
6. Write a Java program to sort an array without using built-in methods.