Data Types In Java! Trivia Questions Quiz

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 Catherine Halcomb
C
Catherine Halcomb
Community Contributor
Quizzes Created: 1428 | Total Attempts: 5,897,934
Questions: 10 | Attempts: 123

SettingsSettingsSettings
Data Types In Java! Trivia Questions Quiz - Quiz


Below is a Data Types in Java Trivia Questions Quiz. There are two data types in java, and this is primitive and non-primitive. The main difference between the two is that one is already defined by java, and the programmer creates the other. Take the quiz and get to refresh your knowledge of the two and how they are applied.


Questions and Answers
  • 1. 

    Groovy has a literal form for each of its numeric literals except BigDecimal.

    • A.

      True

    • B.

      False

    Correct Answer
    B. False
    Explanation
    There is a literal form for a BigDecimal value namely 1.23G.

    Rate this question:

  • 2. 

    Following this Groovy declaration, Integer i, the variable i has a fixed, non-changing type.

    • A.

      True

    • B.

      False

    Correct Answer
    A. True
    Explanation
    True, variable i's type cannot be changed.

    Rate this question:

  • 3. 

    Groovy is like JavaScript in that you can enclose a double quoted string within a single quoted string (e.g. 'Hello "John" ') without escaping each double quote.

    • A.

      True

    • B.

      False

    Correct Answer
    A. True
    Explanation
    True. This is also true for reversing the roles of the quotes, e.g. "Hello 'John' ".

    Rate this question:

  • 4. 

    The find operator =~ returns a Boolean value indicating whether one string is found within another string.

    • A.

      True

    • B.

      False

    Correct Answer
    B. False
    Explanation
    The find operator =~ returns a Matcher value, not a Boolean value. The Matcher value itself can be tested for its truthiness.

    Rate this question:

  • 5. 

    What is printed by the following Groovy code?def x = 1/2def y = 1/2println x+y 

    • A.

      0 // since 1/2 uses integer division to produce 0

    • B.

      1 // since 1/2 + 1/2 = 1

    • C.

      1.0 // since .5 + .5 = 1.0

    Correct Answer
    C. 1.0 // since .5 + .5 = 1.0
    Explanation
    Since both x and y are dynamically typed and are assigned 1/2 or .5, the answer is 1.0.

    Rate this question:

  • 6. 

    The subscript read operator a[b] is mapped to

    • A.

      Get()

    • B.

      GetAt()

    • C.

      Index()

    • D.

      IndexAt()

    Correct Answer
    B. GetAt()
    Explanation
    It's mapped to "getAt()" method.

    Rate this question:

  • 7. 

    String interpolation performs expression evaluation when the expression following $ is enclosed in (two words) _____ _____.

    Correct Answer
    curly braces
    curly brackets
    Explanation
    "1+1 = ${1+1}" // curly braces

    Rate this question:

  • 8. 

    If you want integer division results in Groovy, you must "escape" to Java coding

    • A.

      True

    • B.

      False

    Correct Answer
    B. False
    Explanation
    Not true. Use a cast (int) or call the intdiv() method.

    Rate this question:

  • 9. 

    The 'as type' operator acts like a cast operator.

    • A.

      True

    • B.

      False

    Correct Answer
    A. True
    Explanation
    True (mostly). Groovy's 'as type' may actually generate some code to do the conversion. A Java cast rarely generates code.

    Rate this question:

  • 10. 

    The Number class is augmented in Groovy with the method(s):

    • A.

      Upto()

    • B.

      Downto()

    • C.

      Step()

    • D.

      All of the above

    Correct Answer
    D. All of the above
    Explanation
    In Groovy, the Number class is augmented with the methods "upto()", "downto()", and "step()". The "upto()" method is used to iterate from the current number up to a specified number, while the "downto()" method is used to iterate from the current number down to a specified number. The "step()" method is used to iterate from the current number to a specified number with a given step size. Therefore, all of the given options are correct as they represent the methods that are added to the Number class in Groovy.

    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 10, 2024
    Quiz Edited by
    ProProfs Editorial Team
  • Aug 07, 2014
    Quiz Created by
    Catherine Halcomb
Back to Top Back to top
Advertisement
×

Wait!
Here's an interesting quiz for you.

We have other quizzes matching your interest.