Java Test - 1

A vibrant illustration of a person programming in Java, surrounded by code snippets and Java-related symbols, emphasizing a tech-savvy environment.

Java Mastery Quiz

Test your knowledge and skills in Java programming with our comprehensive quiz designed for enthusiasts and professionals alike. Whether you're just starting your programming journey or looking to brush up on your Java skills, this quiz offers a mix of theoretical and practical questions to challenge you.

Features of the quiz include:

  • 10 engaging multiple-choice questions
  • Immediate feedback on your answers
  • Perfect for self-assessment and learning
10 Questions2 MinutesCreated by CodingNinja479
Name:
What will be the output of the following Java code?
 
class increment {
   public static void main(String args[]) {
        int g = 3;
        System.out.print(++g * 8);
   }
}
32
33
24
25
Which environment variable is used to set the java path?
JAVA_PATH
JAVA_HOME
JAVAPATH
JAVA
What will be the output of the following Java program?
 
class variable_scope {
  public static void main(String args[]) {
      int x;
      x = 5; {
        int y = 6;
        System.out.print(x + " " + y);
      }
     System.out.println(x + " " + y);
  }
}
Compilation Error
Runtime Error
5 6 5 6
5 6 5
What will be the output of the following Java program?
 
class Output {
  public static void main(String args[]) {
      int arr[] = {1, 2, 3, 4, 5};
      for ( int I = 0; I < arr.length - 2; ++i)
              System.out.println(arr[i] + " ");
    }
 }
1 2 3 4 5
1 2 3 4
1 2 3
1 2
What will be the output of the following Java code?
 
class String_demo {
   public static void main(String args[]) {
     char chars[] = {'a', 'b', 'c'};
     String s = new String(chars);
     System.out.println(s);
  }
}
Abc
A
B
C
What will be the output of the following Java program?
 
class recursion {
  int func (int n) {
      int result; if (n == 1) return 1;
      result = func (n - 1); return result;
  }
}
 
class Output {
  public static void main(String args[]) {
  recursion obj = new recursion() ;
  System.out.print(obj.func(5));
 }
}
1
120
0
None of above
Which of the following is a superclass of every class in Java?
ArrayList
Object class
Abstract class
String
What will be the output of the following Java code snippet? Import java.util.*; class Arraylists { public static void main(String args[]) { ArrayLists obj = new ArrayLists(); obj.add("A"); obj.add("B"); obj.add("C"); obj.add(1, "D"); System.out.println(obj); } }
[A, D, C]
[A, B, C]
[A, B, C, D]
[A, D, B, C]
Which one of the following is not an access modifier?
Private
Public
Void
Protected
{"name":"Java Test - 1", "url":"https://www.quiz-maker.com/QPREVIEW","txt":"Test your knowledge and skills in Java programming with our comprehensive quiz designed for enthusiasts and professionals alike. Whether you're just starting your programming journey or looking to brush up on your Java skills, this quiz offers a mix of theoretical and practical questions to challenge you.Features of the quiz include:10 engaging multiple-choice questionsImmediate feedback on your answersPerfect for self-assessment and learning","img":"https:/images/course1.png"}
Powered by: Quiz Maker