Q.1 How many characters are represented by the ASCII character set?

Ans. ASCII is a 7-bit character set that can represent 27 = 128 characters.

Q.2 What is the difference between false and "false"?

Ans. false is a boolean literal representing a false value, while "false" is a string literal representing the text "false".

Q.3 What is a character set?

Ans. A character set is a defined list of characters that a language can recognize. It includes:

Q.4 What is an escape sequence in Java?

Ans. An escape sequence is a set of characters starting with a backslash (\) that has a special meaning to the Java compiler. Examples include \n for a new line, \' for a single quote, and \t for a tab.

Q.5 State the escape sequences for the horizontal tab and the new line character.

Ans. The escape sequence for a horizontal tab is '\t', and for a new line, it is '\n'.

Q.6 int res = 'A'; What is the value of res?

Ans. The value of res is 65, as 'A' corresponds to 65 in ASCII.

Q.7 Write the output for the following:
System.out.println("Incredible" + "\n" + "world");

Ans.

Incredible
world
Q.8 What are tokens in Java? Name any three tokens.

Ans. All characters in a Java program are grouped into symbols called tokens. A computer program consists of statements, each composed of various components. Each component of a programming statement is referred to as a token. Keywords, identifiers, and literals are examples of tokens in Java.

Q.9 What are keywords? Give an example.

Ans. Keywords are reserved words that the Java compiler reserves for its own use, meaning they cannot be used as names for variables or methods. They have special meanings in the Java compiler. For example, void and public are keywords.

Q.10 What are identifiers?

Ans. Identifiers are names used in a program to label different components such as variables, methods, classes, and objects.

Q.11 What are literals in Java?

Ans. Literals are sequences of characters that represent constant values in a program. They are stored in variables and can consist of digits, letters, and other characters.

Q.12 Identify the literals and their types from the list below:
  • 0.5
  • false
  • 'A'
  • "a"
Q.13 What are primitive data types?

Ans. Primitive data types are the fundamental data types of Java programming language. They are also called Intrinsic or built-in data types because they are the part of the language. There are 8 primitive data types in Java: byte, short, int, long, float, double, char, and boolean.

Q.14 Arrange the following primitive data types in ascending order of their size: char, double, byte.

Ans. byte, char, double.

Q.15 What are the two basic kinds of data types in Java?

Ans. The two basic kinds of data types in Java are primitive data types (e.g., int and char) and reference data types.

Q.16 State the number of bytes occupied by char and int data types.

Ans. The char data type occupies 2 bytes, and the int data type occupies 4 bytes.

Q.17 State the difference between a boolean literal and a character literal.

Ans. A boolean literal represents a value of either true or false, and it uses 1 byte of storage. A character literal, on the other hand, represents a single character enclosed in single quotes, such as 'G', and it uses 2 bytes of storage.

Q.18 Write one difference between primitive data types and composite data types.

Ans. Primitive data types are the fundamental data types in Java, like int and char. In contrast, composite (or non-primitive) data types, such as arrays, are derived from primitive data types and can hold multiple values.

Q.19 What are the default values of the primitive data types int and float?

Ans. The default value of int is 0, and the default value of float is 0.0f.

Q.20 Name the primitive data type in Java that is a 64-bit integer and one that represents a single 16-bit Unicode character.

Ans. The 64-bit integer data type in Java is long, and the data type that represents a single 16-bit Unicode character is char.

Q.21 State one difference between a floating point literal and a double literal.

Ans. A floating point literal requires 4 bytes of storage, while a double literal requires 8 bytes of storage.

Q.22 What are the key rules and guidelines for naming identifiers or variables in programming?

Ans.

Q.23 Classify the following as primitive or non-primitive data types: char, arrays, int, classes.

Ans.

Q.24 Can a Java program have two different variables named counter and Counter?

Ans. Yes, Java is case-sensitive, so counter and Counter would be recognized as two distinct identifiers.

Q.25 Give one example each of a primitive data type and a composite data type.

Ans. Primitive data type: int and long. Composite data type: class and array.

Find it difficult?

Don’t lose heart, don’t be under confident, just be consistent in your preparation and be sure of everything you’ve studied. You can request a class so that we can help you understant this topic.

Feel Confident?

Your first step in learning any new topic is to be aware of your strengths and weaknesses. Once you know this, your self-preparation can be meaningful and result-oriented. Attempt an quiz to get tested.