Curriculum
Course: Complete Java Programming Course
time left:
:
:
Login

Curriculum

Complete Java Programming Course

Quiz

Data Types and Variables

Submit quiz
Once you submit, you will no longer be able to change your answers. Are you sure you want to submit the quiz?
    1.
    What is the size of a 'char' in Java?
    8 bits
    16 bits
    32 bits
    64 bits
    2.
    What is the result of type casting a larger value to a smaller data type?
    Compilation error
    Runtime error
    Truncation
    3.
    What is the range of values for a Java byte data type?
    -128 to 127
    0 to 255
    -32768 to 32767
    -2147483648 to 2147483647
    4.
    Consider the following Java code snippet: double a = 9.97; int b = (int) a; System.out.println(b);
    10
    Compilation error
    9
    5.
    Which of these is a valid literal for a double data type in Java?
    1.0
    1e2
    Both a and b
    6.
    Which suitable data type would you choose to represent a person's age in Java?
    byte
    short
    int
    long
    7.
    Which of these is an implicit type conversion in Java?
    int to long
    double to int
    long to int
    char to double
    8.
    What is the default value of a boolean variable in Java?
    true
    0
    false
    null
    9.
    Which of the following statements about type conversion is correct in Java?
    Byte can be directly converted to char without any explicit casting.
    An int can hold all valid byte values without explicit casting.
    A double can be automatically converted to float without any data loss.
    Casting a double to a float always preserves the precision.
    10.
    Which of these is an example of explicit type casting in Java?
    int a = 100;
    double b = a;
    int c = (int) b;
    float d = 10.5f;
    11.
    Given the following Java code, what is the result? char c = 'A'; int i = c;
    Compilation error
    Runtime error
    i is 65
    i is 'A'
    12.
    Which keyword is used for automatic type conversion in Java?
    auto
    dynamic
    cast
    None of the above
    13.
    Which of these is not a primitive data type in Java?
    int
    float
    String
    char
    14.
    Which of these is not a legal identifier in Java?
    3DPoint
    _myVar
    $helloWorld
    15.
    In Java, which of these is true about implicit type casting?
    Implicit casting occurs when converting from a larger to a smaller numeric type.
    It is also known as widening conversion.
    It may not result in loss of precision.
    It needs to be done manually by the programmer.
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15