Java Basics

Last Updated :
Discuss
Comments

Question 1

What is the correct way to declare a Java main method?

  • public static void Main(String[] args)

  • public void main(String args)

  • public static void main(String[] args)

  • private static void main(String args[])

Question 2

What is the output of the following Java program?

Java
public class Main {
    public static void main(String[] args) {
        int my_var = 20;
        System.out.println(my_var);
    }
}


  • 20

  • Compilation Error


  • Runtime Error


  • Undefined Behavior

Question 3

Which of the following is NOT a Feature of Java?

  • Platform independence

  • Object-oriented


  • Dynamically typed language

  • Robust

Question 4

Which component is responsible for converting bytecode to machine code?

  • Java Compiler

  • JDK


  • JVM

  • JRE


Question 5

Which part of the JDK is used to run Java programs?

  • javac

  • JRE

  • Javadoc

  • JAR

Question 6

Java code is compiled into which intermediate form?

  • Assembly

  • Bytecode

  • Binary

  • Machine code

Question 7

Which Java feature ensures code written once can run anywhere?


  • Platform independence

  • Multithreading

  • Security

  • Performance

There are 7 questions to complete.

Take a part in the ongoing discussion