Java Programming Basics - Q&A Notes
1. What is Java?
Java is a high-level, object-oriented, and platform-independent programming language developed by Sun Microsystems
in 1995. It is used to build various types of applications such as web, mobile, and enterprise software.
2. What are the basic features of Java?
- Simple: Easy syntax and automatic memory management.
- Object-Oriented: Supports encapsulation, inheritance, and polymorphism.
- Platform-Independent: Runs on JVM, ensuring portability.
- Secure: Built-in security features and sandboxing.
- Robust: Strong error handling and memory management.
- Multithreaded: Supports concurrent execution.
- Architecture Neutral: Bytecode can run on any platform.
- High Performance: JIT compiler boosts execution speed.
- Distributed: Tools for building distributed systems.
- Dynamic: Loads classes at runtime.
3. What is JVM?
JVM stands for Java Virtual Machine. It is a part of the Java Runtime Environment (JRE) and is responsible for
executing Java bytecode. It provides platform independence and handles memory management, garbage collection, and
security.
4. Write a simple Java program.
public class HelloWorld {
public static void main(String[] args) {
Java Programming Basics - Q&A Notes
System.out.println("Hello, World!");
Explanation:
- 'public class HelloWorld': Declares a class.
- 'public static void main': Entry point of the program.
- 'System.out.println': Prints message to console.
5. What are primitive data types and variables in Java?
Java has 8 primitive data types: byte, short, int, long, float, double, char, and boolean. A variable is a container that
holds data of a particular type.
Example: int age = 25; // 'age' is a variable of type int.
6. What are Java keywords?
Java keywords are reserved words that have predefined meanings in the language and cannot be used for variable
names or identifiers.
Examples: class, public, static, void, int, if, else, return, new, etc.