Ultimate Quiz On Java Skills! Trivia

Reviewed by Editorial Team
The ProProfs editorial team is comprised of experienced subject matter experts. They've collectively created over 10,000 quizzes and lessons, serving over 100 million users. Our team includes in-house content moderators and subject matter experts, as well as a global network of rigorously trained contributors. All adhere to our comprehensive editorial guidelines, ensuring the delivery of high-quality content.
Learn about Our Editorial Process
| By Maverick_virgo
M
Maverick_virgo
Community Contributor
Quizzes Created: 1 | Total Attempts: 14,511
| Attempts: 14,515
SettingsSettings
Please wait...
  • 1/10 Questions

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

    • C,C++,JAVA
    • C,JAVA,RUBY
    • C++,JAVA,BASIC
    • BASIC,FORTRAN,JAVA
    • C++,JAVA,C#
Please wait...
About This Quiz

Dive into the 'Ultimate Quiz on Java Skills! Trivia' to assess and enhance your understanding of Java as both a programming language and a platform. This quiz covers fundamental concepts, syntax, and code analysis to ensure a robust grasp of Java essentials, making it ideal for learners and professionals.

Ultimate Quiz On Java Skills! Trivia - Quiz

Quiz Preview

  • 2. 

    The package __________ is automatically imported in every java program.

    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:

  • 3. 

    How will you describe Java?

    • Programming Language

    • Platform

    • Both Programming Language and Platform

    • Abstract Machine

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

    Rate this question:

  • 4. 

    Java Is Structured Programming Language.

    • True

    • False

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

    Rate this question:

  • 5. 

    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.");

    • Java is fun! Programming needs practice.

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

    • Programming needs practice Explore the world of Java.

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

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

    Correct Answer
    A. 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:

  • 6. 

    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--);

    • 0 -32 -7

    • 0.5 32 6

    • 0 40 -7

    • 0.5 -32 -7

    • 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:

  • 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 = 20 b = 10

    • A = 10 b = 20

    • A = 30 b = 10

    • A = 10 b = 30

    • Compile-time error

    Correct Answer
    A. 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 function Math.ceil(-99.9) return?

    • -99

    • 99.0

    • 100.0

    • -99.0

    • -100.0

    Correct Answer
    A. -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:

  • 9. 

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

    • 1 4

    • 14

    • 4

    • 7

    • Nothing. It will give compile-time error.

    Correct Answer
    A. 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:

  • 10. 

    Which of the following are legal identifiers in Java?

    • 1abc

    • Abc_1

    • OneAbc

    • Final

    • $while

    Correct Answer(s)
    A. Abc_1
    A. OneAbc
    A. $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:

Quiz Review Timeline (Updated): Mar 21, 2023 +

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.