🚗
🤖
🗼 💻 🖥️ ðŸ§
🖥️
🗼
✨ ICSE Computer Applications Assessment ✨
Computism Lab
Class 8 - Java Programming & Basic Concepts
ðŸ§
🤖
Subject: Computer Applications (Java)
Max Marks: 70
Time Allowed: 2 Hours
Section A: Multiple Choice Questions on Datatypes10 Marks
- What is the size of an `int` data type in Java?
- a. 2 bytes
- b. 4 bytes
- c. 8 bytes
- d. 1 byte
- Which of the following is a non-primitive (reference) data type in Java?
- a. int
- b. char
- c. String
- d. double
- What is the default value of a `boolean` data type variable in Java?
- a. true
- b. false
- c. 0
- d. null
- Which data type occupies the maximum memory space in Java?
- a. float
- b. int
- c. double
- d. short
- What is the size of a `char` data type in Java?
- a. 1 byte
- b. 2 bytes
- c. 4 bytes
- d. 8 bytes
- Which of these integer data types has the smallest range?
- a. int
- b. long
- c. byte
- d. short
- Which data type is appropriate for storing fractional numbers like `99.99` by default?
- a. float
- b. double
- c. int
- d. char
- What kind of literal is `true` in Java?
- a. Integer literal
- b. Boolean literal
- c. Character literal
- d. String literal
- Which category do primitive data types belong to?
- a. User-defined
- b. Reference
- c. Built-in / Fundamental
- d. Derived
- What is the default data type for whole integer numbers in Java expressions?
- a. byte
- b. short
- c. int
- d. long
Section B: Assertion-Based MCQs on Java Basics10 Marks
-
Assertion (A): Java is a platform-independent language.
Reason (R): Java code is compiled into bytecode which can execute on any system with a JVM.
a) Both A and R are true, and R is the correct explanation of A.
b) Both A and R are true, but unrelated.
c) A is true, R is false.
d) A is false, R is true. -
Assertion (A): Variable names in Java are case-sensitive.
Reason (R): `Rate` and `rate` are interpreted as two distinct identifiers by the Java compiler.
a) Both A and R are true, and R is the correct explanation of A.
b) Both are true, unrelated.
c) A is true, R is false.
d) A is false, R is true. -
Assertion (A): Every executable Java application requires a `main()` method.
Reason (R): The JVM looks for the `main()` method as the starting point for program execution.
a) Both A and R are true, and R is the correct explanation of A.
b) Both are true, unrelated.
c) A is true, R is false.
d) A is false, R is true. -
Assertion (A): Semicolons are optional at the end of statements in Java.
Reason (R): Every complete Java statement must be terminated with a semicolon.
a) Both are true.
b) A is true, R is false.
c) A is false, but R is true.
d) Both are false. -
Assertion (A): Comments are executed during runtime to calculate values.
Reason (R): Comments are ignored by the compiler and are meant only for documentation.
a) Both are true.
b) A is true, R is false.
c) A is false, but R is true.
d) Both are false. -
Assertion (A): The assignment operator (`=`) is used to test equality between two variables.
Reason (R): Equality is tested using the relational operator `==`.
a) Both A and R are true.
b) A is true, R is false.
c) A is false, but R is true.
d) Both are false. -
Assertion (A): The `print()` method prints text and keeps the cursor on the same line.
Reason (R): `println()` automatically inserts a newline character after printing output.
a) Both A and R are true, and R is the correct explanation of A.
b) Both are true, unrelated.
c) A is true, R is false.
d) A is false, R is true. -
Assertion (A): Keywords can be used as variable names in Java.
Reason (R): Keywords are reserved words with pre-defined meanings in the Java language.
a) Both A and R are true.
b) A is true, R is false.
c) A is false, but R is true.
d) Both are false. -
Assertion (A): The `if-else` statement is used for decision-making in Java.
Reason (R): It allows alternate blocks of code to execute depending on a boolean condition.
a) Both A and R are true, and R is the correct explanation of A.
b) Both are true, unrelated.
c) A is true, R is false.
d) A is false, R is true. -
Assertion (A): Division of two integers using `/` yields an integer result, discarding fractional parts.
Reason (R): Integer division truncates any decimal remainder in Java.
a) Both A and R are true, and R is the correct explanation of A.
b) Both are true, unrelated.
c) A is true, R is false.
d) A is false, R is true.
Section C: True or False5 Marks
- Java is an object-oriented programming language. (True / False)
- A variable name in Java can start with a numeric digit. (True / False)
- The postfix increment operator (`++`) increases the value of the variable after its evaluation. (True / False)
- The `else` block is compulsory whenever an `if` statement is used. (True / False)
- Single-line comments in Java begin with `//`. (True / False)
Section D: Find the Output (Prefix/Postfix & If-Else Snippets)20 Marks
-
Snippet 1:
int a = 5;
int b = ++a + a++;
System.out.println("a = " + a + ", b = " + b); -
Snippet 2:
int x = 10;
int y = x++ + 3;
System.out.println("x = " + x + ", y = " + y); -
Snippet 3:
int m = 8;
int n = --m - m--;
System.out.println("m = " + m + ", n = " + n); -
Snippet 4:
int a = 12;
if (a % 2 == 0) {
System.out.println("Even");
} else {
System.out.println("Odd");
} -
Snippet 5:
int p = 5, q = 10;
if (p > q) {
System.out.println(p);
} else {
System.out.println(q);
} -
Snippet 6:
int val = 4;
int res = --val * 2;
System.out.println("val = " + val + ", res = " + res); -
Snippet 7:
int num = 7;
if (num > 5) {
num += 3;
} else {
num -= 2;
}
System.out.println(num); -
Snippet 8:
int x = 2;
int y = x++ + ++x + x;
System.out.println(y); -
Snippet 9:
int score = 75;
if (score >= 90) {
System.out.println("Grade A");
} else if (score >= 60) {
System.out.println("Grade B");
} else {
System.out.println("Grade C");
} -
Snippet 10:
int c = 3;
int d = c++ * ++c;
System.out.println("c = " + c + ", d = " + d);
Section E: Java Basic Programs (5 Programs)25 Marks
-
Program 1: Even or Odd Number Checker
Write a Java program to check whether a given integer (`int n = 14`) is even or odd using an `if-else` statement.
-
Program 2: Greatest of Three Numbers
Write a Java program to find and print the greatest among three given numbers (`a = 15`, `b = 25`, `c = 20`) using nested `if-else`.
-
Program 3: Simple Interest Calculator
Write a Java program to calculate Simple Interest given Principal (`P = 5000`), Rate (`R = 7.5`), and Time (`T = 3` years) using the formula $SI = (P \times R \times T) / 100$.
-
Program 4: Print Numbers from 1 to 10
Write a Java program using a `for` loop to print numbers from 1 to 10, each separated by a space or on a new line.
-
Program 5: Vowel or Consonant Checker
Write a Java program using a `switch` statement to check whether a given character (`char ch = 'e'`) is a vowel or a consonant.
⭐ Best of Luck for Your Examination! Code with Precision and Confidence! 🚀
CREATED BY BIJAN KRISHNA PAUL
No comments:
Post a Comment