
ICSE Board Class 10 Computer Applications (Group III Section – A) Question Paper 2026 with Solutions PDFs is available here for download.ICSE Board Class 10 Computer Applications (Group III Section – A) Paper 2026 was held on March 23, 2026. The ICSE Class 10 Computer Applications exam consists of a 100-mark total, divided into an 80-mark theory paper 2 hours and a 20-mark internal assessment practical/project. The theory paper features Section A (40 marks, compulsory) and Section B (60 marks, 4 of 6 questions). ICSE Board Class 10 question paper followed the latest syllabus and exam pattern prescribed by ICSE. ICSE Board Class 10 the examination was held in the first half from 10:30 AM to 1:30 PM. Students can download the official paper in PDF format for reference.
| ICSE Board Class 10 Computer Applications (Group III Section – A) Question Paper | Download PDF | Check Solutions |

The full form of JVM is:
Step 1: Understanding the Concept:
The Java Virtual Machine (JVM) is an abstract computing machine that enables a computer to run Java programs as well as programs written in other languages that are also compiled to Java bytecode.
Step 2: Detailed Explanation:
Java is designed to be "Write Once, Run Anywhere" (WORA).
The Java compiler (\texttt{javac) converts the source code (.java) into bytecode (.class).
The JVM acts as the runtime engine that interprets or JIT-compiles this bytecode into machine-specific code for execution.
Step 3: Final Answer:
The standard full form is Java Virtual Machine. Quick Tip: Remember that the JVM is platform-dependent (different for Windows, Mac, Linux), but it allows the Java Bytecode to be platform-independent.
Which of the following occupies 2 bytes of storage?
Step 1: Understanding the Concept:
Data types in Java have fixed sizes.
Integer literals like 25 are treated as \texttt{int (4 bytes).
String literals like "AM" are objects and take variable space based on length + overhead.
Floating point literals like 35.2 are treated as \texttt{double (8 bytes).
Character literals are enclosed in single quotes and represent a single 16-bit Unicode character.
Step 2: Detailed Explanation:
Option (A): 25 is an \texttt{int literal \(\rightarrow\) 4 bytes.
Option (B): "AM" is a \texttt{String (not a primitive).
Option (C): 35.2 is a \texttt{double literal \(\rightarrow\) 8 bytes.
Option (D): '\(\backslash\backslash\)' is a character literal (representing a single backslash using an escape sequence). In Java, the \texttt{char data type is 16-bit (2 bytes) because it uses the Unicode system.
Step 3: Final Answer:
The character literal '\(\backslash\backslash\)' occupies 2 bytes of storage. Quick Tip: In Java, \texttt{char} is 2 bytes (Unicode), unlike C/C++ where it is 1 byte (ASCII).
In a statement \(c = c + (x * d + e);\), which variable is an accumulator?
Step 1: Understanding the Concept:
An accumulator is a variable that collects or "accumulates" a running total or a result over time.
It typically appears on both sides of the assignment operator in the form \(Var = Var + value\).
Step 2: Detailed Explanation:
In the statement \(c = c + (x * d + e)\):
The variable \texttt{c is having a value added to its existing value, and the new total is stored back into \texttt{c.
Variables \(x, d,\) and \(e\) are only used to provide values for the expression but are not updated themselves in this specific operation.
Step 3: Final Answer:
The variable \texttt{c acts as the accumulator. Quick Tip: Look for the variable that is on both the left-hand side (LHS) and right-hand side (RHS) of the assignment in an addition operation.
Which of the following is NOT an access specifier?
Step 1: Understanding the Concept:
Java provides keywords to control the visibility/accessibility of classes, methods, and variables. These are called Access Specifiers.
Step 2: Detailed Explanation:
Java has four levels of access, but only three keywords:
1. \texttt{public: Accessible everywhere.
2. \texttt{protected: Accessible within the same package and by subclasses.
3. \texttt{private: Accessible only within the same class.
4. Default: If no specifier is used, it is accessible only within the same package. This is often called "package-private", but \texttt{package itself is not a keyword used as an access specifier.
Step 3: Final Answer:
\texttt{package is not an access specifier keyword in Java. Quick Tip: Note that "default" access has no keyword. Using the keyword \texttt{package} will result in a syntax error if used as a specifier.
What is the output of the statement \(Math.pow(36, 6/5)\); ?
Step 1: Understanding the Concept:
This question tests integer division and the \texttt{Math.pow() function.
In Java, when two integers are divided, the result is an integer (the fractional part is truncated).
Step 2: Detailed Explanation:
1. Evaluate the expression \(6/5\):
Since both 6 and 5 are integers, integer division occurs.
\[ 6 / 5 = 1 \]
2. Evaluate \(Math.pow(36, 1)\):
The \texttt{Math.pow(base, exponent) function returns the value of base raised to the power of exponent.
\[ 36^1 = 36 \]
3. Return type:
\texttt{Math.pow always returns a \texttt{double value. So, 36 becomes 36.0.
Step 3: Final Answer:
The output is 36.0. Quick Tip: Always check if division is between integers. If it were \(6.0/5\), the result would be 1.2, and the answer would change significantly!
Read the if program segment given below:
\texttt{if (a > b)
z = 25;
else
z = 35;
Which one of the following is the correct conversion of the if segment to ternary?
Step 1: Understanding the Concept:
The ternary operator (\texttt{?:) is a shorthand for an \texttt{if-else statement.
Syntax: \texttt{variable = (condition) ? value_if_true : value_if_false;
Step 2: Detailed Explanation:
The given code logic is:
- If \(a > b\) is true, \(z\) becomes 25.
- If \(a > b\) is false, \(z\) becomes 35.
Converting this:
Condition: \(a > b\)
True Part: 25
False Part: 35
Resulting Statement: \(z = (a > b) ? 25 : 35;\)
Step 3: Final Answer:
Option (B) matches the logic correctly. Quick Tip: Mnemonic: "Question the condition (?) then Choose (:)" - \texttt{Condition ? True : False}.
The output of the statement:
\texttt{System.out.println(Character.toUpperCase('b') + 2);
is:
Step 1: Understanding the Concept:
This involves a wrapper class method and type promotion in expressions.
When a character is used with a mathematical operator (+), it is promoted to its ASCII (Unicode) integer value.
Step 2: Detailed Explanation:
1. \texttt{Character.toUpperCase('b') converts the lowercase 'b' to uppercase 'B'.
2. The ASCII value of 'A' is 65, so 'B' is 66.
3. The expression becomes: \(66 + 2\).
4. \(66 + 2 = 68\).
Step 3: Final Answer:
The output is 68. Quick Tip: ASCII Values to remember: 'A' = 65, 'a' = 97, '0' = 48.
Consider the following statements:
Name the objects of the class given above:
Step 1: Understanding the Concept:
In Java, the syntax for object creation is:
\texttt{ClassName objectName = new ClassName();
Step 2: Detailed Explanation:
In the first statement: \texttt{Computer is the class, and \texttt{desktop is the object (variable name).
In the second statement: \texttt{Computer is the class, and \texttt{Mainframe is the object (variable name).
Note: Java is case-sensitive. \texttt{desktop and \texttt{Mainframe are exactly as written in the code.
Step 3: Final Answer:
The objects are \texttt{desktop and \texttt{Mainframe. Quick Tip: Class names usually start with uppercase letters (e.g., Computer), while objects (instance variables) usually start with lowercase letters, though the user can name them anything.
The earth spins on its axis completing one rotation in a day. The earth moves around the sun in 365 days to complete one revolution. What is concept depicted in the given picture?
Step 1: Understanding the Concept:
A nested loop is a loop inside another loop. The inner loop completes all its iterations for every single iteration of the outer loop.
Step 2: Detailed Explanation:
The revolution of the Earth around the Sun (outer cycle) takes 365 days.
During each of those 365 days, the Earth completes one full rotation on its axis (inner cycle).
Think of it as:
\texttt{for (int day = 1; day <= 365; day++) \{ // Outer loop (Revolution)
\indent for (int hour = 1; hour <= 24; hour++) \{ // Inner loop (Rotation)
\indent \
\
Step 3: Final Answer:
This represents a Nested loop. Quick Tip: Think of a clock: the minute hand moving (inner) for every step of the hour hand (outer) is also a nested loop.
In the following method prototype to accept a character, an integer and return YES or NO, fill in the blank to complete the method prototype.
\texttt{public _______ someMethod(char ch, int n)
Step 1: Understanding the Concept:
The return type of a method indicates the type of data the method sends back to the caller.
Step 2: Detailed Explanation:
The problem states the method should return "YES" or "NO".
"YES" and "NO" are text literals, which in Java are represented by the \texttt{String class.
- \texttt{boolean returns true/false.
- \texttt{int returns whole numbers.
- \texttt{double returns decimal numbers.
Step 3: Final Answer:
The correct return type is \texttt{String. Quick Tip: If the question asked to return "True" or "False" as words, it's a \texttt{String}. If it asked to return logic values, it would be \texttt{boolean}.
In a calculator which Java feature allows multiple methods named calculate() for the different operations?
Step 1: Understanding the Concept:
Polymorphism (specifically Static Polymorphism or Method Overloading) allows multiple methods in the same class to have the same name but different parameters.
Step 2: Detailed Explanation:
Having multiple methods named \texttt{calculate() that perform different tasks (like \texttt{calculate(int a, int b) for addition and \texttt{calculate(double r) for area) is a classic example of method overloading.
This falls under the broad OOP concept of Polymorphism ("many forms").
Step 3: Final Answer:
The feature is polymorphism. Quick Tip: Same name + Different parameters = Method Overloading (a type of Polymorphism).
Assertion (A): The result of the Java expression \(3 + 7/2\) is 6.
Reason (R): According to the hierarchy of operators in Java, addition is done first followed by division.
Step 1: Understanding the Concept:
Operator precedence determines the order in which operators are evaluated. Multiplicative operators (\texttt{*, /, %) have higher precedence than additive operators (\texttt{+, -).
Step 2: Detailed Explanation:
1. Evaluate Expression \(3 + 7/2\):
Division (\texttt{/) happens first. \(7 / 2 = 3\) (integer division).
Then addition (\texttt{+) happens. \(3 + 3 = 6\).
So, Assertion (A) is True.
2. Evaluate Reason (R):
The reason states addition is done first. This is False. Division has higher precedence.
Step 3: Final Answer:
(A) is true but (R) is false. Quick Tip: Think of BODMAS. In Java, it's roughly: Parentheses \(\rightarrow\) Increment/Decrement \(\rightarrow\) Multiplicative \(\rightarrow\) Additive.
What is the type of parameter to be given for the method parseInt()?
Step 1: Understanding the Concept:
The method \texttt{Integer.parseInt() is used to convert a numerical value represented as text into a primitive \texttt{int.
Step 2: Detailed Explanation:
The signature of the method is \texttt{public static int parseInt(String s).
It takes a \texttt{String as input and parses it into an integer. For example, \texttt{Integer.parseInt("123") returns the number 123.
Step 3: Final Answer:
The parameter type is \texttt{String. Quick Tip: Wrapper class parse methods (like \texttt{parseDouble}, \texttt{parseLong}) always take a \texttt{String} as a parameter.
To extract the word NOW from the word “ACKNOWLEDGEMENT”, Java statement “ACKNOWLEDGEMENT”.substring(3, ___) is used. Choose the correct number to fill in the blank.
Step 1: Understanding the Concept:
The \texttt{substring(int beginIndex, int endIndex) method extracts characters from \texttt{beginIndex to \texttt{endIndex - 1.
Step 2: Detailed Explanation:
Let's index the string "ACKNOWLEDGEMENT":
A(0), C(1), K(2), N(3), O(4), W(5), L(6), E(7)...
To get "NOW":
- Starting index = 3 (inclusive).
- Ending index = 6 (exclusive). Index 6 corresponds to 'L', so it will stop at index 5 ('W').
Step 3: Final Answer:
The number is 6. Quick Tip: Formula: \texttt{endIndex = beginIndex + length\_of\_desired\_string}.
Length of "NOW" is 3. So, \(3 + 3 = 6\).
String a[ ] = {"Atasi", "Aditi", "Anant", "Amit", "Ahana"};
System.out.println(a[1].charAt(1) + "*" + a[2].charAt(2));
The output of the above statement is:
Step 1: Understanding the Concept:
This tests array indexing, string methods, and string concatenation.
Step 2: Detailed Explanation:
1. \texttt{a[1] is "Aditi".
2. \texttt{a[1].charAt(1): Character at index 1 of "Aditi" is 'd' (A is index 0).
3. \texttt{a[2] is "Anant".
4. \texttt{a[2].charAt(2): Character at index 2 of "Anant" is 'a' (A=0, n=1, a=2).
5. Concatenation: 'd' + "*" + 'a' results in the string "d*a".
Step 3: Final Answer:
The output is d*a. Quick Tip: Array and String indices both start at 0. Don't confuse the two!
Which of the following String methods returns a negative value?
Step 1: Understanding the Concept:
Different string methods return different types of results (int, boolean, char).
Step 2: Detailed Explanation:
- \texttt{length() returns the number of characters (always 0 or positive).
- \texttt{equals() returns \texttt{boolean (true or false).
- \texttt{compareTo() subtracts ASCII values. It returns:
\indent 0 if strings are equal.
\indent Positive value if the first string is lexicographically greater.
\indent Negative value if the first string is lexicographically smaller.
- \texttt{charAt() returns a \texttt{char.
Step 3: Final Answer:
\texttt{compareTo() can return a negative value. Quick Tip: \texttt{"Apple".compareTo("Banana")} will return a negative integer because 'A' < 'B'.
An array with 3 elements is arranged in ascending order as follows: [4, 1, 3] \(\rightarrow\) [1, 4, 3] \(\rightarrow\) [1, 3, 4]. Name the technique used:
Step 1: Understanding the Concept:
Bubble sort works by repeatedly swapping adjacent elements if they are in the wrong order.
Step 2: Detailed Explanation:
Initial: [4, 1, 3]
Step 1: Compare 4 and 1. Since \(4 > 1\), swap them. \(\rightarrow\) [1, 4, 3].
Step 2: Compare 4 and 3. Since \(4 > 3\), swap them. \(\rightarrow\) [1, 3, 4].
Since we are swapping adjacent elements to "bubble" the largest value to the end, this is Bubble Sort.
Step 3: Final Answer:
The technique is Bubble sort. Quick Tip: Bubble sort = Adjacent Swaps.
Selection sort = Find Minimum and Swap with Start.
The sales made by 5 salesmen selling 5 products is stored in a two-dimensional array of integer data type. How many bytes does the array occupy?
Step 1: Understanding the Concept:
Total memory occupied by an array = Total number of elements \(\times\) Size of data type.
Step 2: Key Formula or Approach:
\[ Total Elements = Rows \times Columns \]
\[ Total Bytes = Total Elements \times Size of int (4 bytes) \]
Step 3: Detailed Explanation:
Number of rows (salesmen) = 5
Number of columns (products) = 5
Total elements = \(5 \times 5 = 25\).
In Java, an \texttt{int occupies 4 bytes.
Total bytes = \(25 \times 4 = 100\).
Step 4: Final Answer:
The array occupies 100 bytes. Quick Tip: Standard sizes in Java: byte(1), char/short(2), int/float(4), long/double(8).
Assertion (A): The substring() method modifies the original String.
Reason (R): The substring() method can extract part of a String from a specific index.
Step 1: Understanding the Concept:
In Java, Strings are **immutable**. This means once a String object is created, its value cannot be changed.
Step 2: Detailed Explanation:
- Assertion (A): The \texttt{substring() method creates a *new* String containing the requested part. It does not change the original String. Thus, (A) is False.
- Reason (R): This is exactly what \texttt{substring() does—it extracts a part of the string. Thus, (R) is True.
Step 3: Final Answer:
(A) is false but (R) is true. Quick Tip: Any method that seems to "change" a String (like \texttt{replace}, \texttt{toUpperCase}, \texttt{substring}) actually returns a brand new String object.
In constructor overloading all constructors should have the same class but with a different set of ________.
Step 1: Understanding the Concept:
Constructor overloading is a technique in Java in which a class can have any number of constructors that differ in parameter lists.
Step 2: Detailed Explanation:
Constructors must have the same name as the class and no return type. To distinguish between multiple constructors, they must have a different "signature", which means:
1. Different number of parameters.
2. Different types of parameters.
3. Different order of parameters.
Step 3: Final Answer:
They must have a different set of Parameters. Quick Tip: Overloading = Same name, Different parameters. This applies to both methods and constructors.
Rewrite the following program segment using a for loop.
\texttt{int a = 5, b = 10;
while (b > 0) \{
\indent b -= 2;
\
System.out.println(a * b);
Step 1: Understanding the Concept:
A \texttt{while loop can be converted to a \texttt{for loop by identifying the initialization, condition, and update (iteration) components.
Step 2: Detailed Explanation:
- Initialization: \texttt{b = 10
- Condition: \texttt{b > 0
- Update: \texttt{b -= 2
In the \texttt{while loop, the update happens inside the block. In a \texttt{for loop, it's placed in the header.
Step 3: Final Answer:
\begin{verbatim
int a = 5;
int b;
for (b = 10; b > 0; b -= 2) {
// The loop body in the original was just the update
System.out.println(a * b);
\end{verbatim Quick Tip: A \texttt{for} loop structure is: \texttt{for(init; condition; update)}.
Evaluate the Java expression: \(x = a * b % (++c) + (++a) + (--b);\) if \(a = 7, b = 8, c = 2.\)
Step 1: Understanding the Concept:
Java evaluates expressions from left to right while respecting operator precedence and handling increment/decrement operations as they occur.
Step 2: Detailed Explanation:
Given: \(a=7, b=8, c=2\)
Expression: \(x = a * b % (++c) + (++a) + (--b);\)
Evaluation steps (Left to Right):
1. \(a * b\): Uses current values \(7 * 8 = 56\).
2. \texttt{++c: Pre-increment \(c\) from 2 to 3.
3. \texttt{%: \(56 % 3 = 2\) (since \(3 \times 18 = 54, rem = 2\)).
4. \texttt{++a: Pre-increment \(a\) from 7 to 8.
5. \texttt{--b: Pre-decrement \(b\) from 8 to 7.
6. Addition: \(2 (result of %) + 8 (new a) + 7 (new b)\).
7. Total: \(2 + 8 + 7 = 17\).
Step 3: Final Answer:
\(x = 17\). Quick Tip: Pre-increment (\texttt{++i}) changes the value before use. Post-increment (\texttt{i++}) changes it after use in that specific step.
Write the Java expression to find the sum of cube root of x and the absolute value of y.
Step 1: Understanding the Concept:
The \texttt{Math class in Java provides methods for common mathematical operations.
Step 2: Detailed Explanation:
- Cube root function: \texttt{Math.cbrt(variable)
- Absolute value function: \texttt{Math.abs(variable)
- To find the sum, we simply use the \texttt{+ operator between these two function calls.
Step 3: Final Answer:
\texttt{Math.cbrt(x) + Math.abs(y) Quick Tip: Don't confuse \texttt{Math.sqrt()} (square root) with \texttt{Math.cbrt()} (cube root).
Users must be above 10 years to open a self-operated bank account. Write this logic using a ternary operator and store the result (the eligibility message) in a String variable named idStatus and print it.
Step 1: Understanding the Concept:
The ternary operator takes the form \texttt{(condition) ? (true_value) : (false_value).
Step 2: Detailed Explanation:
1. Condition: User must be above 10 (\texttt{age > 10).
2. Variable: \texttt{idStatus of type \texttt{String.
3. True message: "Eligible" (or similar positive message).
4. False message: "Not Eligible" (or similar negative message).
Step 3: Final Answer:
\texttt{String idStatus = (age > 10) ? "Eligible" : "Not Eligible";
System.out.println(idStatus); Quick Tip: Ensure the variable type (\texttt{String}) matches the values being returned by the ternary operator.
Give the output of the following program segment:
\texttt{String S = "GRACIOUS".substring(4);
System.out.println(S);
System.out.println("GLAMOROUS".endsWith(S));
Step 1: Understanding the Concept:
- \texttt{substring(int beginIndex) extracts the string from that index to the end.
- \texttt{endsWith(String suffix) checks if a string ends with the specified suffix and returns a boolean.
Step 2: Detailed Explanation:
1. \texttt{"GRACIOUS".substring(4):
G(0), R(1), A(2), C(3), I(4), O(5), U(6), S(7).
So, \texttt{S = "IOUS".
2. \texttt{System.out.println(S) prints IOUS.
3. \texttt{"GLAMOROUS".endsWith("IOUS"):
The word "GLAMOROUS" ends with the letters "O", "U", "S". It does not end with "IOUS".
Wait, let's look closer: GLAMOR-OUS. The suffix is "OUS", not "IOUS".
Actually, "GLAMOROUS" ends with "OUS". Therefore, "GLAMOROUS".endsWith("IOUS") is false.
*Self-correction*: Checking spelling: G-L-A-M-O-R-O-U-S. Index of 'I' is not present.
Wait, looking at the word: "GLAMOROUS". It ends in "OUS". "GRACIOUS" ends in "IOUS". So "GLAMOROUS".endsWith("IOUS") returns false.
Step 3: Final Answer:
\texttt{IOUS
false Quick Tip: Check letter by letter. Suffix matching is case-sensitive and literal.
Give the output of the following program segment and mention how many times the loop is executed.
\texttt{int K = 1;
do \{
\indent K += 2;
\indent System.out.println(K);
\ while (K <= 6);
Step 1: Understanding the Concept:
A \texttt{do-while loop is an exit-controlled loop. It executes the body at least once before checking the condition.
Step 2: Detailed Explanation:
Initial: \(K = 1\).
Iteration 1:
- \(K = K + 2 = 3\).
- Print 3.
- Condition: \(3 \leq 6\) is True.
Iteration 2:
- \(K = 3 + 2 = 5\).
- Print 5.
- Condition: \(5 \leq 6\) is True.
Iteration 3:
- \(K = 5 + 2 = 7\).
- Print 7.
- Condition: \(7 \leq 6\) is False.
Loop terminates.
Step 3: Final Answer:
Output:
3
5
7
Number of times executed: 3. Quick Tip: In a \texttt{do-while} loop, even if the condition is false initially, the loop runs exactly once.
The following program segment calculates and displays the factorial of a number. [Example: Factorial of 5 is \(1 \times 2 \times 3 \times 4 \times 5 = 120\)]
\texttt{int P, n = 5, f = 0;
for (P = n; P > 0; P--) \{
\indent f *= P;
\
System.out.println(f);
Step 1: Understanding the Concept:
Factorial is the product of all positive integers up to \(n\). To compute a product, the initial value of the variable must be 1 (identity for multiplication).
Step 2: Detailed Explanation:
In the given code:
- Initialization: \texttt{f = 0.
- First loop step (\(P=5\)): \texttt{f = f * 5 \(\rightarrow\) \texttt{0 * 5 = 0.
- Subsequent steps: Since \texttt{f is already 0, any multiplication will result in 0.
The logic is flawed for calculating factorial (it should have been \texttt{f = 1), but the output of the \textit{provided code is 0.
Step 3: Final Answer:
The output is 0. Quick Tip: When calculating sums, initialize to 0. When calculating products (like Factorial), initialize to 1.
For the array U[ ][ ] = {{4, 5}, {7, 2}, {19, 4}, {7, 43}}, find the maximum element and the index of the minimum element.
Step 1: Understanding the Concept:
A 2D array is indexed by row and column \texttt{[row][col], starting from \texttt{0.
Step 2: Detailed Explanation:
Array Layout:
Row 0: 4, 5
Row 1: 7, 2
Row 2: 19, 4
Row 3: 7, 43
1. Finding Maximum:
Comparing all values \{4, 5, 7, 2, 19, 4, 7, 43\, the largest is 43.
2. Finding Minimum:
Comparing all values, the smallest is 2.
Locating 2 in the array: It is in the 2nd row (index 1) and 2nd column (index 1).
Index = [1][1].
Step 3: Final Answer:
Max: 43, Min Index: [1][1]. Quick Tip: Always count from zero. Row indices here go 0-3 and Column indices go 0-1.
Write the statement that swaps the first element and the second element using the third variable. Fill in the blanks.
\texttt{int a = 10, b = 20, t;
______ = a;
a = ______;
b = ______;
Step 1: Understanding the Concept:
To swap two values, we need a temporary location to hold one value so it isn't lost when we overwrite the first variable.
Step 2: Detailed Explanation:
1. Save the value of \texttt{a in \texttt{t (\texttt{t = 10).
2. Move the value of \texttt{b into \texttt{a (\texttt{a = 20).
3. Move the saved value from \texttt{t into \texttt{b (\texttt{b = 10).
Step 3: Final Answer:
\texttt{t = a;
a = b;
b = t; Quick Tip: Think of it as swapping juice between two glasses using an empty third glass.
Define a class named StepTracker with the following specifications:
Member Variables:
String name – stores the user’s name.
int sw – stores the total number of steps walked by the user.
double cb – stores the estimated calories burned by the user.
double km – stores the estimated distance walked in kilometers.
Member Methods:
void accept() – to input the name and the steps walked using Scanner class methods only.
void calculate() – calculates calories burned and distance in km based on steps walked.
Step 1: Understanding the Concept:
A class definition includes declaring member variables (state) and member methods (behavior).
Step 2: Detailed Explanation:
- We declare the variables \texttt{name, sw, cb, km with appropriate data types.
- The \texttt{accept() method uses \texttt{Scanner to get input.
- The \texttt{calculate() method applies the logic (since the table is missing in the prompt, standard estimations are used for demonstration).
Step 3: Final Answer:
The class \texttt{StepTracker is defined with the requested fields and basic input/logic methods. Quick Tip: Always remember to import \texttt{java.util.Scanner} when using the Scanner class.
Write a program to accept the designations of 100 employees in a single dimensional array. Accept the designation from the user and print the total number of employees with the designation given by the user as input.
Step 1: Understanding the Concept:
This problem requires a linear search through a String array and a counter variable.
Step 2: Detailed Explanation:
1. Create a String array of size 100.
2. Use a loop to fill the array with user input.
3. Accept the search term (target designation).
4. Loop through the array again, comparing each element with the target using \texttt{equalsIgnoreCase().
5. Increment the count whenever a match is found.
Step 3: Final Answer:
A complete Java program that counts specific designations in an array of 100. Quick Tip: When comparing Strings, always use \texttt{.equals()} or \texttt{.equalsIgnoreCase()}, never \texttt{==}.
Write a program to accept a two-dimensional integer array of order \(4 \times 5\) as input from the user. Check if it is a Sparse Matrix or not. A matrix is considered to be a sparse, if the total number of zero elements is greater than the total number of non-zero elements. Print appropriate messages.
Step 1: Understanding the Concept:
A sparse matrix contains more zeros than non-zero elements. We need nested loops to traverse the 2D array and counters to track both types of values.
Step 2: Detailed Explanation:
1. Declare a 2D array \texttt{int m[4][5].
2. Nested loops: outer loop runs 4 times (rows), inner loop runs 5 times (columns).
3. Inside the inner loop, take input and check if it's zero.
4. After both loops finish, compare the \texttt{zeros counter with the \texttt{nonZeros counter.
5. Print the result based on the comparison.
Step 3: Final Answer:
The provided Java code correctly inputs the matrix and performs the sparsity check. Quick Tip: Total elements in a \(4 \times 5\) matrix is 20. If \texttt{zeros > 10}, it is guaranteed to be sparse.
*The article might have information for the previous academic years, please refer the official website of the exam.