Values and Data Types

ICSE Class 9 Computer Applications · Solutions for Class 9 ICSE Logix Kips Computer Applications with BlueJ Java · 36 solved questions

Exercise
Marks
11 Mark · Multiple Choice Questions

ASCII stands for ...........

Show SolutionHide Solution↓
  • American Standard Code for Information Interchange ✓
  • 21 Mark · Multiple Choice Questions

    ASCII is ...........

    Show SolutionHide Solution↓
  • 7-bit set of codes ✓
  • 31 Mark · Multiple Choice Questions

    Extended ASCII is ...........

    Show SolutionHide Solution↓
  • 8-bit set of codes ✓
  • 41 Mark · Multiple Choice Questions

    Which of the following is not a token?

    Show SolutionHide Solution↓
  • Procedure ✓
  • 51 Mark · Multiple Choice Questions

    Which of the following is a keyword?

    Show SolutionHide Solution↓
  • break ✓
  • 71 Mark · Multiple Choice Questions

    Which of the following is an invalid integer?

    Show SolutionHide Solution↓
  • 199 99 ✓
  • 81 Mark · Multiple Choice Questions

    Which of the following is not a character literal?

    Show SolutionHide Solution↓
  • "t" ✓
  • 91 Mark · Multiple Choice Questions

    Which of the following punctuator is the statement terminator in Java?

    Show SolutionHide Solution↓
  • ; ✓
  • 101 Mark · Multiple Choice Questions

    Which of the following is not a primitive data type in Java?

    Show SolutionHide Solution↓
  • class ✓
  • 111 Mark · Multiple Choice Questions

    Which of the following is the size of a long data type in Java?

    Show SolutionHide Solution↓
  • 64 bits ✓
  • 121 Mark · Multiple Choice Questions

    Which of the following is the size of a boolean data type in Java?

    Show SolutionHide Solution↓
  • 8 bits ✓
  • 1State whether the given statements are True or…

    Java supports the use of the ASCII character set only.
    False

    Solution not available in the source paper.

    2State whether the given statements are True or…

    The smallest unit in a Java program is known as token.
    True

    Solution not available in the source paper.

    3State whether the given statements are True or…

    The Unicode character set uses 8 to 32 bits per character.
    True

    Solution not available in the source paper.

    4State whether the given statements are True or…

    In an escape sequence, a character is preceded by a forward slash (/).
    False

    Solution not available in the source paper.

    5State whether the given statements are True or…

    In Java, an identifier cannot begin with a $ sign.
    False

    Solution not available in the source paper.

    6State whether the given statements are True or…

    The boolean data types are used for storing logical values.
    True

    Solution not available in the source paper.

    7State whether the given statements are True or…

    Java offers five types of tokens.
    True

    Solution not available in the source paper.

    8State whether the given statements are True or…

    The char data type reserves 8 bits in memory.
    False

    Solution not available in the source paper.

    9State whether the given statements are True or…

    If a literal constant contains a decimal point, then it is of the type double by default.
    True

    Solution not available in the source paper.

    10State whether the given statements are True or…

    The modifier final can be applied to a variable declaration to ensure that the value stored in the variable cannot be changed after the variable has been initialised.
    True

    Solution not available in the source paper.

    1Assignment Questions

    What are escape sequences in Java? Give three examples.

    Show SolutionHide Solution↓

    An escape sequence is a set of characters that has a special meaning to the Java compiler. In the escape sequence, a character is preceded by a backslash (\). Some examples of escape sequences are \n, \' and \t.

    2Assignment Questions

    What is the result of evaluating the following expression?
      (1 + 2 * 2) / 2 + 2

    Show SolutionHide Solution↓

        (1 + 2 * 2) / 2 + 2 ⇒ (1 + 4) / 2 + 2
    ⇒ (5) / 2 + 2
    ⇒ 2 + 2
    ⇒ 4

    3Assignment Questions

    What is a token in Java? Name the tokens available in Java.

    Show SolutionHide Solution↓

    All characters in a Java program are grouped into symbols called Tokens. As you know, a computer program consists of a set of instructions called statements. A statement is composed of various components. Each individual component of a programming statement is referred to as a token. Keywords, identifiers, Operators, Separators and literals are three tokens in Java.

    4Assignment Questions

    Why can't you use a keyword as a variable name?

    Show SolutionHide Solution↓

    Keywords are reserved words that have a special meaning to the Java compiler. As Java compiler reserves these words for its own use so they are not available as names for variables or methods.

    5Assignment Questions

    Which of the following are Java keywords?
        input, class, public, int, x, y, radius

    Show SolutionHide Solution↓

    class, public, int are Java keywords.

    6Assignment Questions

    What are identifiers in Java? List three identifier formation rules.

    Show SolutionHide Solution↓

    Identifiers are used to name different parts of a program such as variables, methods, classes, objects, etc. Three identifier formation rules are:

    1. An an identifier can be a sequence of alphabets, digits, underscore and dollar sign characters only.
    2. Identifiers cannot start with a digit.
    3. An identifier must not be a Keyword or a Boolean or null literal.
    7Assignment Questions

    Explain the following statement — "In Java, total, Total, ToTaL, and TOTAL are all different identifiers."

    Show SolutionHide Solution↓

    Java is a case sensitive language. total, Total, ToTaL, and TOTAL have the same set of letters but they differ in the case of these letters. Therefore, Java considers each of them as a different identifier.

    8Assignment Questions

    How would you print characters like \, ' and " in Java?

    Show SolutionHide Solution↓

    We can print characters like \, ' and " using escape sequences i.e. preceding it with a backslash (\) symbol.

    9Assignment Questions

    Distinguish between the following:

    i. Token and Identifier

    Show SolutionHide Solution↓
    TokenIdentifier
    Each individual component of a programming statement is referred to as a token.Identifiers are fundamental building blocks of the program and are used to name different components of a program such as variables, methods and objects.
    Tokens in Java are categorised into 5 types — Keywords, Identifiers, Literals, Punctuators, Operators.Identifier is a type of token in Java.

    ii. Keyword and Identifier

    KeywordIdentifier
    Keywords have a special meaning for Java compiler.Identifiers are used to name different components of a program such as variables, methods and objects.
    Keywords are reserved by the compiler for its own use.An identifier must not be a Keyword.

    iii. Character and String Constant

    Character ConstantString Constant
    Character Constants are written by enclosing a character within a pair of single quotes.String Constants are written by enclosing a set of characters within a pair of double quotes.
    Character Constants are assigned to variables of type char.String Constants are assigned to variables of type String.

    iv. Integer and float Constant

    Integer ConstantFloat Constant
    Integer Constants represent whole number values like 2, -16, 18246, 24041973, etc.Float Constants represent fractional numbers like 3.14159, -14.08, 42.0, 675.238, etc.
    Integer Constants are assigned to variables of data type — byte, short, int, long, charFloat Constants are assigned to variables of data type — float, double
    10Assignment Questions

    Distinguish between "A" and 'A'.

    Show SolutionHide Solution↓

    "A" is a string literal of length 1 containing the letter A in uppercase whereas 'A' is a character literal having value of A in uppercase.

    11Assignment Questions

    Describe primitive data types in Java.

    Show SolutionHide Solution↓

    Primitive data types are fundamental data types that are an integral part of the Java language and are used to declare a variable.

    12Assignment Questions

    List the size of primitive data types in Java.

    Show SolutionHide Solution↓
    Data TypeSize in Bytes
    byte1
    short2
    int4
    long8
    float4
    double8
    char2
    boolean1
    13Assignment Questions

    Which integer and floating point data types take up the same number of bits in computer's memory?

    Show SolutionHide Solution↓

    Both, int and float take up 32 bits in memory. Similarly, both long and double take up 64 bits in memory.

    14Assignment Questions

    What is variable initialisation in Java? What are the default values of the following type of variables:
    short, int, long, float, double, and char.

    Show SolutionHide Solution↓

    Variable initialisation means assigning value to a variable for the first time. Below are the default values of the different data types:

    Data TypeDefault Value
    short0
    int0
    long0L
    float0.0f
    double0.0d
    char'\u0000'

    Press ↓ to reveal a solution and move to the next question. Back to Solutions for Class 9 ICSE Logix Kips Computer Applications with BlueJ Java.