Java is a simple programming language. Writing, compilation, and debugging a program is very easy in Java. It helps to create reusable code.
Objects are stored in heap memory. Heap memory exists inside the JVM, and the JVM runs inside the RAM.
Garbage Collection makes Java memory efficient because the garbage collector removes unreferenced objects from heap memory.
Access Specifiers are:
In Java, data types define the type of data a variable can hold. Java has two main categories of data types:
byte, short, int, long, double, float, char, boolean.String, Arrays, Classes, etc.The Scanner class is used to get input from the user. We create a Scanner object, pass System.in as a parameter, and call methods like nextInt() to get integers or next()/nextLine() to get strings.
Wrapper classes are classes for primitive data types. They are used to convert primitive types into objects.
The final keyword is used to restrict modification:
static keyword. Shared across all objects of the class. Memory is allocated once during class loading.finalize() is a method in Java used for garbage collection. It is called by the Garbage Collector before destroying an object.
Yes, the program will successfully execute. In Java, there is no specific rule for the order of specifiers.
The code will compile successfully, but the JVM will throw a runtime error: NoSuchMethodError: main. Reason: JVM requires public static void main(String[] args) as the entry point. Since the method isn’t static, it cannot be called without creating an object — but no object is created by the JVM.
Yes, the main method can be overloaded. You can define multiple main() methods with different parameter types.
No, private methods cannot be overridden because they are not inherited by subclasses and are accessible only within the class where they are defined.
Signup