Ultimate Quiz On Java Skills! Trivia

Approved & Edited by ProProfs Editorial Team
The editorial team at ProProfs Quizzes consists of a select group of subject experts, trivia writers, and quiz masters who have authored over 10,000 quizzes taken by more than 100 million users. This team includes our in-house seasoned quiz moderators and subject matter experts. Our editorial experts, spread across the world, are rigorously trained using our comprehensive guidelines to ensure that you receive the highest quality quizzes.
Learn about Our Editorial Process
| By Maverick_virgo
M
Maverick_virgo
Community Contributor
Quizzes Created: 1 | Total Attempts: 14,501
Questions: 10 | Attempts: 14,501

SettingsSettingsSettings
Ultimate Quiz On Java Skills! Trivia - Quiz

.


Questions and Answers
  • 1. 

    How will you describe Java?

    • A.

      Programming Language

    • B.

      Platform

    • C.

      Both Programming Language and Platform

    • D.

      Abstract Machine

    Correct Answer
    C. Both Programming Language and Platform
    Explanation
    Java acts both as a programming language as well as a platform for several applications.

    Rate this question:

  • 2. 

    Java Is Structured Programming Language.

    • A.

      True

    • B.

      False

    Correct Answer
    B. False
    Explanation
    Java is Object Oriented Programming Language.

    Rate this question:

  • 3. 

    Which of the following are legal identifiers in Java?

    • A.

      1abc

    • B.

      Abc_1

    • C.

      OneAbc

    • D.

      Final

    • E.

      $while

    Correct Answer(s)
    B. Abc_1
    C. OneAbc
    E. $while
    Explanation
    A is wrong as it starts with a digit. D is wrong as it is a keyword. Identifiers in Java must start with a letter, Dollar sign($) or an Underscore(_) and must not be a keyword.

    Rate this question:

  • 4. 

    The package __________ is automatically imported in every java program.

    Correct Answer(s)
    java.lang, java.lang.*, java.lang.*;
    Explanation
    In every Java program, the package "java.lang" is automatically imported. This package contains fundamental classes and interfaces that are essential for any Java program to run. The wildcard character "*" indicates that all classes and interfaces within the "java.lang" package are imported. Therefore, the correct answer is "java.lang, java.lang.*, java.lang.*".

    Rate this question:

  • 5. 

    What will the function Math.ceil(-99.9) return?

    • A.

      -99

    • B.

      99.0

    • C.

      100.0

    • D.

      -99.0

    • E.

      -100.0

    Correct Answer
    D. -99.0
    Explanation
    ceil() returns the smallest whole number less than or equal to the given argument. It returns a double type value.

    Rate this question:

  • 6. 

    What will be the output of the following code segment?String one="one";String two="two";String One=new String(one);String Two=two;if(one==One)System.out.println("Java is fun!");if(one.equals(One)==true)System.out.println("Programming needs practice.");if(one==Two)System.out.println("OOP is the way!");if(two.equals(Two)==true)System.out.println("Explore the world of Java.");

    • A.

      Java is fun! Programming needs practice.

    • B.

      Java is fun! Programming needs practice. Explore the world of Java.

    • C.

      Programming needs practice Explore the world of Java.

    • D.

      Programming needs practice. OOP is the way! Explore the world of Java.

    • E.

      Java is fun! Programming needs practice. OOP is the way! Explore the world of Java.

    Correct Answer
    C. Programming needs practice Explore the world of Java.
    Explanation
    == operator compares the memory locations, which is never same for two different objects whereas equals() compares the contents.

    Rate this question:

  • 7. 

    What will be the output of the following code segment?class Number{int a;public static void main(String ar[]){ a=10;int b=20;a=a+b;b=a-b;a=a-b;System.out.println("a = "+a);System.out.println("b = "+b);}}

    • A.

      A = 20 b = 10

    • B.

      A = 10 b = 20

    • C.

      A = 30 b = 10

    • D.

      A = 10 b = 30

    • E.

      Compile-time error

    Correct Answer
    E. Compile-time error
    Explanation
    Non-static variable cannot be referenced from a static context. a is a non-static variable, it cannot be referenced from within main() which is static.

    Rate this question:

  • 8. 

    What will the following code segment print?int i; for(i=1;i<=4;i=i+3); System.out.println(i);

    • A.

      1 4

    • B.

      14

    • C.

      4

    • D.

      7

    • E.

      Nothing. It will give compile-time error.

    Correct Answer
    D. 7
    Explanation
    The value will be printed only when the loop is terminated. Since it's a one-line loop so it won't repeat the printing statement. Loop terminated when i becomes 7. So 7 will be printed.

    Rate this question:

  • 9. 

    What will be the output of the following code segment?int a = 4, b = 8, c = -5; System.out.println(a/b+"\n"+(++c*b--)+" "+a--*b/c--);

    • A.

      0 -32 -7

    • B.

      0.5 32 6

    • C.

      0 40 -7

    • D.

      0.5 -32 -7

    • E.

      0 -32 -7

    Correct Answer
    A. 0 -32 -7
    Explanation
    The code segment first performs the division operation a/b, which results in 0. Then, it concatenates the result with the value of (++c*b--) and (a--*b/c--).

    The expression (++c*b--) increments the value of c by 1 and multiplies it by b, which is 8. The post-decrement operator (b--) is then applied, reducing the value of b by 1. The result of this expression is -32.

    The expression (a--*b/c--) multiplies the value of a (4) by b (7) and divides it by c (-6). The post-decrement operator (a--) is then applied, reducing the value of a by 1. The result of this expression is -7.

    Therefore, the output of the code segment is 0 -32 -7.

    Rate this question:

  • 10. 

    Which of the following group consists of only Object-Oriented languages?

    • A.

      C,C++,JAVA

    • B.

      C,JAVA,RUBY

    • C.

      C++,JAVA,BASIC

    • D.

      BASIC,FORTRAN,JAVA

    • E.

      C++,JAVA,C#

    Correct Answer
    E. C++,JAVA,C#
    Explanation
    The group consisting of C++, JAVA, and C# consists of only Object-Oriented languages. C++ is a general-purpose programming language that supports both procedural and object-oriented programming paradigms. JAVA is a widely used object-oriented programming language known for its platform independence. C# is a modern, general-purpose, object-oriented programming language developed by Microsoft. All three languages have features and syntax that support object-oriented programming concepts such as encapsulation, inheritance, and polymorphism.

    Rate this question:

Quiz Review Timeline +

Our quizzes are rigorously reviewed, monitored and continuously updated by our expert board to maintain accuracy, relevance, and timeliness.

  • Current Version
  • Mar 21, 2023
    Quiz Edited by
    ProProfs Editorial Team
  • Sep 03, 2010
    Quiz Created by
    Maverick_virgo
Back to Top Back to top
Advertisement
×

Wait!
Here's an interesting quiz for you.

We have other quizzes matching your interest.