Cognizant Interview SQL Java
Cognizant Interview SQL Java
• Platform Independent
• Object-Oriented
• Robust and Secure
• High Performance via Just-In-Time compiler
• Multithreaded and Portable
Example:
1
6. What is method overloading and overriding?
Methods Can have both concrete & abstract All methods abstract (Java 7)
9. What is encapsulation? How is it implemented? Encapsulation hides internal details using private
variables and public getters/setters.
class Person {
private String name;
public String getName() { return name; }
public void setName(String n) { name = n; }
}
10. What is polymorphism? Give real-time examples. Polymorphism = many forms. Real-time: Printer
class printing PDF, DOC, Images.
• Overloading = compile-time
• Overriding = runtime
11. What is exception handling in Java? Managing runtime errors using try , catch , finally ,
and throw/throws .
2
14. Checked vs Unchecked Exceptions
String No Yes
StringBuilder Yes No
• Set: No duplicates
• List: Ordered with duplicates
• Map: Key-value pairs
20. What is the use of generics in Java? Ensures type safety at compile time.
21. What is multithreading? Running multiple threads (tasks) simultaneously. Achieved via Thread
or Runnable .
3
23. What are static variables and methods? Belong to class, not object.
25. What is garbage collection? Process of freeing memory by destroying unused objects, done by JVM
automatically.