---
One Mark Answers
1. What are variables in Java?
Variables are containers used to store data values in a program.
2. What is typecasting in Java?
Typecasting is converting one data type into another type.
3. How do you declare an array in Java?
int arr[] = new int[5];
4. Explain the main method in Java.
It is the starting point of a Java program:
public static void main(String[] args)
5. What are literals in Java?
Fixed values used in a program (like 10, 3.5, 'a', "Hello").
6. What is a constructor in Java?
A special method used to initialize objects.
7. Explain method overloading in Java.
Having multiple methods with the same name but different parameters.
8. What is a package in Java?
A package is a group of related classes and interfaces.
9. What is Object-Oriented Programming?
A programming style based on objects and classes.
10. What are the main principles of OOP?
Encapsulation, Inheritance, Polymorphism, Abstraction.
11. What is inheritance?
It allows one class to acquire properties of another class.
12. What is an interface?
An interface is a collection of abstract methods.
13. Difference between abstract class and interface.
Abstract class can have both abstract and concrete methods;
Interface has only abstract methods (till Java 7).
14. What is the “super” keyword?
Used to refer to the parent class.
15. What is static in Java?
Static members belong to the class, not to objects.
16. What is exception handling?
The mechanism to handle runtime errors in a program.
17. What is a try–catch block?
A block used to catch and handle exceptions.
18. What is the finally block?
A block that always executes, even if an exception occurs.
19. What is an exception?
An unwanted event that stops normal program execution.
20. What are checked exceptions?
Exceptions checked during compile-time.
21. What are unchecked exceptions?
Exceptions checked during runtime.
22. What is the throws keyword?
Used to declare that a method may throw an exception.
23. Difference between throw and throws.
throw is used to throw an exception manually.
throws is used in method declaration.
24. What is a thread?
A thread is the smallest unit of execution in a program.
---
Thread & JDBC Questions
25. Difference between a process and a thread.
Process is a program in execution;
Thread is a part of a process.
26. What is multithreading?
Running multiple threads at the same time.
27. What are the states of a thread?
New, Runnable, Running, Blocked, Terminated.
28. What is JDBC?
Java Database Connectivity – used to connect Java with databases.
29. Types of JDBC drivers.
Type-1: JDBC-ODBC
Type-2: Native API
Type-3: Network Protocol
Type-4: Thin Driver (Pure Java)
30. Difference between ArrayList and LinkedList.
ArrayList is faster for accessing;
LinkedList is faster for insertion and deletion.
---