Java Internal Exam – 10 Marks Answers
(Exam Ready)
Unit 1: Introduction to Java
Main features of Java
Java is simple, object-oriented, platform independent, secure, multithreaded, and robust.
Difference between C++ and Java
Aspect C++ Java
Platform Platform dependent Platform independent
Pointers Supports pointers No explicit pointers
Inheritance Multiple inheritance Only through interfaces
Memory Management Manual (delete) Automatic (Garbage
Collection)
Define JDK, JRE, JVM
Term Definition
JDK Java Development Kit – includes tools,
compilers, JRE
JRE Java Runtime Environment – provides
libraries and JVM
JVM Java Virtual Machine – executes bytecode
Bytecode in Java
Intermediate code generated by the compiler, executed by JVM.
Syntax of Hello World Program
class Hello {
public static void main(String[] args) {
[Link]("Hello World");
}
}
Variable and Constant
Term Definition Example
Variable Storage location with int x = 10;
changeable value
Constant Fixed value declared with final double PI = 3.14;
final
== vs .equals()
Operator Use
== Compares reference/address of objects
.equals() Compares contents of objects
Four Java Keywords
Keyword Use
class Define a class
public Access modifier
static Used for class-level methods/variables
final Make constants or prevent inheritance
Type Casting
Converting one data type to another. Example: int a = (int) 3.5;
Method in Java
Block of code executed when invoked. Example: int add(int a, int b) { return a+b; }