Cognizant Interview SQL Java (1)
Cognizant Interview SQL Java (1)
11. What is exception handling in Java? Exception handling in Java is a powerful mechanism that
handles runtime errors, maintaining the normal flow of application execution. Java provides five
keywords: try , catch , throw , throws , and finally .
Example:
1
13. Use of final, finally, and finalize()?
• final : Restricts user. Variables can’t be changed, methods can’t be overridden, and classes
can’t be inherited.
• finally : Executes code after try-catch, used for cleanup like closing connections.
• finalize() : Method invoked by garbage collector before object destruction.
• ArrayList : Backed by dynamic array. Fast for retrieval, slow for insertion/deletion.
• LinkedList : Uses doubly linked list. Fast for insertion/deletion, slower for random access.
• HashMap : Allows one null key and multiple null values, not synchronized.
• Hashtable : Doesn’t allow null keys or values, synchronized (thread-safe).
// List
for(String item : list) {
System.out.println(item);
}
// Map
for(Map.Entry<String, String> entry : map.entrySet()) {
System.out.println(entry.getKey() + ": " + entry.getValue());
}
2
HTML Interview Questions with Answers
1. What is HTML? HTML stands for HyperText Markup Language. It is the standard language for
creating web pages by structuring content using elements.
2. What are semantic tags in HTML? Semantic tags clearly define their meaning: <header> ,
<footer> , <article> , <section> , <nav> , etc. Help with SEO and accessibility.
4. Purpose of ``? Declares the HTML version used (HTML5). Helps browser render the page correctly.
6. Types of input in HTML5? text , email , password , number , range , date , color ,
file , search , url , etc.
7. Use of the `` tag? Defines metadata about the HTML document (charset, description, author,
viewport for responsiveness).
9. Purpose of the `` tag? Defines a form to collect user input. Contains controls like input, textarea,
submit.
1. Reverse of a String
2. Factorial Code
3
int fact = 1;
for(int i = 1; i <= n; i++) {
fact *= i;
}
3. Sum of 2 Numbers
int sum = a + b;
System.out.println("Sum: " + sum);
if(num % 2 == 0)
System.out.println("Even");
4
else
System.out.println("Odd");
8. Palindrome Check
HR Questions (Cognizant)
1. Self Introduction Start with name, education background, technical skills, certifications, project
experience, achievements, and hobbies. Keep it under 2 minutes.
• Project Title
• Technologies Used
• Role and Contribution
• Outcome
• Challenges faced and how you solved them
• Java Certification
• AWS Cloud Practitioner
• SQL Databases
4. Relocation “Yes, I am open to relocation as I see it as an opportunity for growth and new
experiences.”
5
8. Why Cognizant? Cognizant is known for its employee-centric culture, global presence, diverse
projects, and excellent learning platforms. I believe it will help me grow.
9. Comfortable Language "I am most comfortable with Java and have also worked with SQL, HTML,
and CSS."
3. What are Lists? Lists are ordered, index-based collections that allow duplicates. Example:
ArrayList , LinkedList .
4. What is Dictionary? In Python: A key-value pair collection. In Java: Equivalent is Map interface
( HashMap , TreeMap ).
5. What is Inheritance? Inheritance allows one class to inherit properties of another using extends .
Promotes code reuse.
6. Tell me about Pillars of OOPS — [Already explained above: Abstraction, Encapsulation, Inheritance,
Polymorphism]
✅ All Interview Questions Fully Answered for SQL, Java, HTML, CSS, JavaScript, Coding, and HR Sections
with complete elaboration.