Interview questions based on covered topic 1
Here are 20 interview questions
OOPs Concepts
1. What is Object-Oriented Programming (OOP), and what are its four main principles?
2. What is the difference between class and object in Java?
3. What is encapsulation in Java, and how does it work?
4. What is inheritance in Java? Can you give an example of it?
5. What is polymorphism? How does method overriding differ from method overloading in Java?
6. What is the difference between an abstract class and an interface in Java?
7. Can you explain the concept of constructor in Java? What is its purpose?
8. What is the role of this keyword in Java? How does it work inside constructors?
9. What is method overloading and method overriding? How are they different?
10. What is the super keyword used for in Java?
---
If-Else
11. How does an if-else statement work in Java? Can you give an example?
12. What is the difference between if-else and switch-case in Java?
13. What happens if you use an if-else statement without curly braces {}? What is the potential issue?
14. How do you implement nested if-else statements? Can you provide an example?
15. What will happen if you use if statements without specifying the else condition?
---
Basic Java String
16. How do you compare two strings in Java? What is the difference between == and .equals()?
17. What is the output of the following code?
String str = "hello";
str = str.concat(" world");
System.out.println(str);
18. How do you reverse a string in Java?
19. How do you convert a string to uppercase and lowercase in Java?
20. What is the purpose of the StringBuilder class, and how does it differ from the String class?
Comments
Post a Comment