The Council for the Indian School Certificate Examinations (CISCE) successfully conducted the ICSE Class 10 Computer Applications (Group III – Section A) Exam on March 23, 2026. The ICSE Class 10 Computer Applications (Group III – Section A) Question Paper with Solution PDF is now available for download.
The ICSE Class 10 Computer Applications (Group III – Section A) paper covered key topics from programming concepts, Java basics, algorithms, and computer fundamentals. Students should focus on understanding programming logic, practicing coding, and applying algorithms to solve problems.
ICSE Class 10 Computer Applications (Group III – Section A) Question Paper 2026 with Solution PDF
| ICSE Class 10 Computer Applications (Group III – Section A) Question Paper 2026 | Download PDF | Check Solution |

The full form of JVM is:
View Solution
Step 1: Understanding the term JVM.
JVM is a very common term in computer science, especially in Java programming. It refers to the environment that allows Java programs to run on different systems.
Step 2: Expanding the abbreviation.
The letters in JVM stand for:
J = Java
V = Virtual
M = Machine
So, JVM means Java Virtual Machine.
Step 3: Checking the options.
(A) Java Visible Machine: Incorrect. ``Visible'' is not the correct word.
(B) Java Virtual Mode: Incorrect. JVM does not stand for Virtual Mode.
(C) Java Virtual Machine: Correct. This is the standard full form of JVM.
(D) Java Visible Mode: Incorrect. This is not related to Java execution.
Step 4: Conclusion.
Therefore, the correct full form of JVM is Java Virtual Machine.
Final Answer: Java Virtual Machine. Quick Tip: JVM stands for \textbf{Java Virtual Machine}. It is responsible for running Java bytecode on different platforms.
Which of the following occupies 2 bytes of storage?
View Solution
Step 1: Understanding byte storage.
In basic computer representation, each character generally occupies 1 byte of storage in simple character encoding. So, to find which option occupies 2 bytes, we count the number of characters.
Step 2: Analyze each option.
25: This contains two digits, but in such school-level questions it is usually treated as a numeric value rather than a two-character text entry.
AM: This contains two characters, A and M. Hence, it occupies 2 bytes.
35.2: This has more than two characters.
\textbackslash\textbackslash: This representation does not match the expected two-byte text answer in the given context.
Step 3: Identify the best answer.
Among the given options, AM clearly consists of two characters. Since each character occupies 1 byte, the total storage required is: \[ 2 bytes \]
Step 4: Conclusion.
Therefore, the option that occupies 2 bytes of storage is AM.
Final Answer: AM. Quick Tip: In basic storage questions, count the number of characters. One character usually occupies 1 byte, so two characters occupy 2 bytes.
In a statement \(c = c + (x * d + e);\) which variable is an accumulator?
View Solution
Step 1: Understand the meaning of accumulator.
An accumulator is a variable that stores a running total. It usually appears on both sides of an assignment statement because its old value is used and then updated with a new value.
Step 2: Examine the given statement.
The statement is: \[ c = c + (x * d + e) \]
Here, the old value of c is taken first. Then some new quantity \((x*d+e)\) is added to it. After that, the result is stored again in c.
Step 3: Identify the accumulator variable.
Since c is the variable that keeps collecting the updated value repeatedly, it acts as the accumulator. The other variables \(x\), \(d\), and \(e\) are only used in the calculation and are not storing the running total.
Step 4: Conclusion.
Therefore, the accumulator variable in the given statement is c.
Final Answer: c. Quick Tip: An accumulator variable usually appears on both sides of the assignment, like \textbf{sum = sum + value}. That repeated updating is the key sign.
Which of the following is NOT an access specifier?
View Solution
Step 1: Understand what an access specifier is.
An access specifier controls the visibility or accessibility of classes, methods, variables, and constructors in object-oriented programming. It decides from where a member can be accessed.
Step 2: Recall the common access specifiers in Java.
In Java, the commonly used access specifiers are:
public -- accessible from everywhere.
private -- accessible only within the same class.
protected -- accessible within the same package and also in subclasses.
default -- when no access specifier is written, it is called default or package-private access.
Step 3: Compare the given options.
(A) private: This is a valid access specifier.
(B) protected: This is also a valid access specifier.
(C) package: This is not an actual keyword used as an access specifier. The correct term is default access or package-private access, but package itself is not an access specifier keyword.
(D) public: This is a valid access specifier.
Step 4: Conclusion.
Therefore, the option which is NOT an access specifier is package.
Final Answer: package. Quick Tip: In Java, \textbf{public, \textbf{private}, and \textbf{protected} are explicit access specifier keywords. If nothing is written, it becomes \textbf{default} or \textbf{package-private} access.
What is the output of the statement Math.pow(36, 6/5); ?
View Solution
Step 1: Understand the function Math.pow(a,b).
The function \textit{Math.pow(a,b) returns the value of \(a^b\), that is, the first argument raised to the power of the second argument.
Here, the statement is: \[ \textit{Math.pow(36, 6/5) \]
Step 2: Evaluate the expression \(6/5\).
In Java, when both numbers are integers, integer division is performed. Since \(6\) and \(5\) are both integers: \[ 6/5 = 1 \]
The fractional part is discarded. So the statement becomes: \[ Math.pow(36, 1) \]
Step 3: Calculate the power.
Now, \[ 36^1 = 36 \]
Since \textit{Math.pow() returns a \textit{double value, the output will be: \[ 36.0 \]
Step 4: Note about the given options.
By Java rules, the mathematically correct output of \textit{Math.pow(36, 6/5) is 36.0.
So:
(A) 36.0 is the correct output.
(D) 6.0 would be incorrect for this exact Java statement.
Final Answer: \(36.0\). Quick Tip: In Java, integer division is very important. When both operands are integers, the decimal part is removed. So \(6/5\) becomes \(1\), not \(1.2\).
Read the if program segment given below:
if (a \(>\) b)
z = 25;
else
z = 35;
Which one of the following is the correct conversion of the if segment to ternary?
View Solution
Step 1: Understand the given if-else statement.
The given program segment says:
\[ if (a>b), then z=25 \] \[ otherwise z=35 \]
So the value assigned to \(z\) depends on the condition \(a>b\).
Step 2: Recall the syntax of the ternary operator.
The ternary operator has the form: \[ condition ? value if true : value if false \]
So, in general: \[ x = condition ? true-value : false-value; \]
Step 3: Apply the ternary form to the given statement.
Here, the condition is: \[ a>b \]
If the condition is true, assign: \[ z=25 \]
If the condition is false, assign: \[ z=35 \]
Therefore, the ternary form becomes: \[ z = a>b ? 25 : 35; \]
Step 4: Compare with the options.
(A) gives the true and false values in reverse order, so it is incorrect.
(B) correctly matches the if-else logic.
(C) and (D) use incorrect ternary syntax.
Hence, the correct conversion is option (B).
Final Answer: \(z = a > b ? 25 : 35;\) Quick Tip: For converting if-else into ternary, always write: \textbf{condition ? true-part : false-part}. The first value comes from the \textbf{if} block, and the second value comes from the \textbf{else} block.
The output of the statement: \texttt{System.out.println(Character.toUpperCase('b') + 2);} is:
View Solution
Step 1: Understand the function \texttt{Character.toUpperCase('b').
The function \texttt{Character.toUpperCase('b') converts the lowercase character \texttt{'b' into its uppercase form. So: \[ \texttt{Character.toUpperCase('b')} = \texttt{'B'} \]
Thus, the character obtained is \texttt{'B'.
Step 2: Find the ASCII value of the character.
In Java, when a character is used in an arithmetic expression, it is automatically converted into its ASCII (or Unicode) integer value. The ASCII value of: \[ \texttt{'B'} = 66 \]
So now the expression becomes: \[ 66 + 2 \]
Step 3: Perform the addition.
Now add 2 to 66: \[ 66 + 2 = 68 \]
So the output printed by the statement will be: \[ 68 \]
Step 4: Compare with the given options.
(A) 66: Incorrect. This is only the ASCII value of \texttt{'B' before adding 2.
(B) 100: Incorrect. This does not match the evaluated result.
(C) 68: Correct. This is the final value after converting \texttt{'b' to \texttt{'B' and adding 2.
(D) 98: Incorrect. This is the ASCII value of lowercase \texttt{'b', not the final result.
Therefore, the correct output is 68.
Final Answer: 68. Quick Tip: In Java, characters used in arithmetic expressions are automatically converted into their ASCII/Unicode values. Also remember: \texttt{'A'} = 65, \texttt{'B'} = 66, and \texttt{'b'} = 98.
Consider the following statements:
\[ \texttt{Computer desktop = new Computer();} \] \[ \texttt{Computer Mainframe = new Computer();} \]
Name the objects of the class given above:
View Solution
Step 1: Understand the structure of object creation in Java.
In Java, an object is created using the syntax: \[ \texttt{ClassName objectName = new ClassName();} \]
Here, the class name tells us which class is being used, and the variable name before the equals sign is the name of the object reference.
Step 2: Identify the class name and object names.
In the given statements: \[ \texttt{Computer desktop = new Computer();} \] \[ \texttt{Computer Mainframe = new Computer();} \]
the class name is \texttt{Computer.
The object names are: \[ \texttt{desktop} and \texttt{Mainframe} \]
So, these are the two objects created for the class \texttt{Computer.
Step 3: Check the options carefully.
(A) Desktop, Mainframe: Incorrect. The first object is \texttt{desktop, not \texttt{Desktop. Java is case-sensitive.
(B) desktop, Mainframe: Correct. These exactly match the object names in the statements.
(C) Computer, Mainframe: Incorrect. \texttt{Computer is the class name, not an object name.
(D) Computer, desktop: Incorrect. \texttt{Computer is again the class name, not an object.
Step 4: Conclusion.
Therefore, the objects of the class given above are desktop and Mainframe.
Final Answer: desktop, Mainframe. Quick Tip: In Java, the word before the object name is the class name, and the word between the class name and the equals sign is the object name. Also remember that Java is case-sensitive.
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?

View Solution
Step 1: Understand the two repeating motions shown in the picture.
The picture shows two repeating processes happening together:
The earth rotates on its own axis once every day.
The earth revolves around the sun once every year.
This means one repeated motion is happening inside another larger repeated motion.
Step 2: Relate this to programming logic.
In programming, when one loop works inside another loop, it is called a nested loop.
Here, daily rotation can be compared to the inner loop, while yearly revolution can be compared to the outer loop.
So, many rotations happen during one revolution, just like many inner loop executions happen during one outer loop cycle.
Step 3: Compare with the given options.
(A) Array: Incorrect. An array is a collection of elements, not a repeated process.
(B) Condition: Incorrect. A condition checks true or false, but the picture shows repetition.
(C) Nested loop: Correct. One repetitive activity is taking place within another repetitive activity.
(D) While loop: Incorrect. A while loop is a single loop, not a loop inside another loop.
Step 4: Conclusion.
Therefore, the concept shown in the picture is nested loop, because one cycle of motion takes place repeatedly inside another larger cycle.
Final Answer: Nested loop. Quick Tip: Whenever one repeated action happens inside another repeated action, think of a nested loop. A common example is days inside months or rotations inside revolutions.
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)} \]
View Solution
Step 1: Understand the meaning of the method prototype.
A method prototype tells us what type of value the method will return after execution. In the given prototype, the method accepts two parameters: \[ \texttt{char ch} \]
and \[ \texttt{int n} \]
Now we have to identify the correct return type for a method that gives an answer in the form of \texttt{YES or \texttt{NO.
Step 2: Relate YES/NO to programming data types.
In programming, a YES/NO type result usually represents a logical decision. A logical decision has only two possible outcomes: \[ \texttt{true} or \texttt{false} \]
In Java, the data type used for such two-way logical outcomes is: \[ \texttt{boolean} \]
So, if the method is supposed to check a condition and indicate whether it is satisfied or not, the most suitable return type is \texttt{boolean.
Step 3: Compare with the given options.
(A) boolean: Correct. It is used when the method returns a logical result such as true or false, which corresponds to YES or NO.
(B) String: Incorrect. A String would return text like \texttt{"YES" or \texttt{"NO", but for logical decisions the standard return type is \texttt{boolean.
(C) int: Incorrect. An integer returns numeric values, not logical results.
(D) double: Incorrect. A double returns decimal values, which is not suitable here.
Step 4: Complete the method prototype.
Thus, the correct method prototype will be: \[ \texttt{public boolean someMethod(char ch, int n)} \]
Hence, the blank must be filled with \texttt{boolean.
Final Answer: boolean. Quick Tip: Whenever a method is expected to return a yes/no type logical result, the most suitable return type in Java is \texttt{boolean}.
In a calculator which Java feature allows multiple methods named calculate() for the different operations?
View Solution
Step 1: Understand what the question is asking.
The question asks which Java feature allows us to use the same method name, such as calculate(), for performing different operations. For example, in a calculator program, we may want one calculate() method for addition, another for subtraction, another for multiplication, and so on.
Step 2: Recall the related Java concept.
In Java, when the same method name is used in different forms, usually with different parameter lists, this is called method overloading. Method overloading is one of the most common examples of polymorphism, specifically compile-time polymorphism.
So, if multiple methods have the same name calculate() but behave differently depending on the arguments passed, the feature involved is polymorphism.
Step 3: Compare the given options.
(A) abstraction: Incorrect. Abstraction hides implementation details and shows only essential features.
(B) inheritance: Incorrect. Inheritance allows one class to acquire the properties and methods of another class.
(C) encapsulation: Incorrect. Encapsulation binds data and methods together and restricts direct access to data.
(D) polymorphism: Correct. Polymorphism allows the same method name to perform different tasks in different situations.
Step 4: Conclusion.
Therefore, the Java feature that allows multiple methods named calculate() for different operations is polymorphism.
Final Answer: polymorphism. Quick Tip: When the same method name is used with different parameters in Java, it is called \textbf{method overloading}, which is an example of \textbf{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.
View Solution
Step 1: Evaluate the expression \(3 + 7/2\) using Java rules.
In Java, when both operands of division are integers, integer division is performed. This means the decimal part is discarded.
So, \[ 7/2 = 3 \]
Now substitute this value into the expression: \[ 3 + 7/2 = 3 + 3 = 6 \]
Hence, the Assertion (A) is true.
Step 2: Check the operator precedence in Java.
According to the operator precedence rules in Java, division is performed before addition, not the other way round.
So in the expression \[ 3 + 7/2 \]
first \(7/2\) is evaluated, and after that \(3\) is added.
Therefore, the statement given in the Reason that addition is done first followed by division is incorrect.
Step 3: Analyze Assertion and Reason together.
Let us compare both statements carefully:
Assertion (A): True, because \(7/2 = 3\) in integer division, and \(3 + 3 = 6\).
Reason (R): False, because Java follows precedence where division is done before addition.
So, the Assertion is correct, but the Reason is wrong.
Step 4: Choose the correct option.
The option that correctly matches this situation is:
\[ (A) (A) is true and (R) is false. \]
Final Answer: (A) Assertion is true and Reason is false. Quick Tip: In Java, always remember two things: \textbf{division has higher precedence than addition}, and \textbf{integer division removes the decimal part}. So \(7/2\) becomes \(3\), not \(3.5\).
What is the type of parameter to be given for the method \texttt{parseInt()}?
View Solution
Step 1: Understand the use of \texttt{parseInt().
In Java, \texttt{parseInt() is a method used to convert a number written in text form into an integer value. This method is commonly written as: \[ \texttt{Integer.parseInt("123")} \]
Here, the method reads the characters inside quotation marks and converts them into the integer 123.
Step 2: Identify the required parameter type.
Since \texttt{parseInt() converts text into an integer, the input must be a String.
That means the method expects something like: \[ \texttt{"45"}, \texttt{"100"}, \texttt{"786"} \]
So, the type of parameter given to \texttt{parseInt() is String.
Step 3: Compare with the given options.
(A) double: Incorrect. A double is already a numeric data type and is not the parameter type for \texttt{parseInt().
(B) String: Correct. \texttt{parseInt() accepts a String and converts it into an integer.
(C) char: Incorrect. A single character is not the standard parameter type for this method.
(D) int: Incorrect. The purpose of \texttt{parseInt() is to produce an int, not to accept one as input.
Step 4: Conclusion.
Therefore, the type of parameter to be given for the method \texttt{parseInt() is String.
Final Answer: String. Quick Tip: Remember: \texttt{Integer.parseInt()} converts a \textbf{String} into an \textbf{int}. Input is text, output is integer.
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.
View Solution
Step 1: Recall how \texttt{substring() works in Java.
In Java, \texttt{substring(beginIndex, endIndex) starts from \texttt{beginIndex and goes up to \texttt{endIndex - 1.
This means the starting index is included, but the ending index is excluded.
Step 2: Write the indices of the word ACKNOWLEDGEMENT.
Let us mark the positions of the letters:
\[ \begin{array}{c c c c c c c c c c c c c c} A & C & K & N & O & W & L & E & D & G & E & M & E & N & T
0 & 1 & 2 & 3 & 4 & 5 & 6 & 7 & 8 & 9 & 10 & 11 & 12 & 13 & 14 \end{array} \]
We want the word NOW.
This begins from: \[ N = 3 \]
and includes: \[ O = 4,\quad W = 5 \]
To stop after \texttt{W, the ending index must be: \[ 6 \]
because index 6 is excluded.
Step 3: Form the substring.
So, \[ \texttt{"ACKNOWLEDGEMENT".substring(3,6)} \]
will give: \[ \texttt{"NOW"} \]
Hence, the correct number to fill in the blank is 6.
Step 4: Conclusion.
Therefore, the correct Java statement is: \[ \texttt{"ACKNOWLEDGEMENT".substring(3,6)} \]
So, the correct answer is 6.
Final Answer: 6. Quick Tip: In Java, \texttt{substring(a,b)} includes index \texttt{a} but excludes index \texttt{b}. Always stop one position after the last character you want.
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:
View Solution
Step 1: Identify the required array elements.
The array is: \[ \texttt{a[ ] = \{"Atasi", "Aditi", "Anant", "Amit", "Ahana"\}} \]
Now check the required positions: \[ \texttt{a[1] = "Aditi"} \] \[ \texttt{a[2] = "Anant"} \]
Step 2: Apply the \texttt{charAt() method.
The expression uses: \[ \texttt{a[1].charAt(1)} \]
In the word \texttt{"Aditi": \[ A = 0,\ d = 1,\ i = 2,\ t = 3,\ i = 4 \]
So, \[ \texttt{a[1].charAt(1) = 'd'} \]
Now: \[ \texttt{a[2].charAt(2)} \]
In the word \texttt{"Anant": \[ A = 0,\ n = 1,\ a = 2,\ n = 3,\ t = 4 \]
So, \[ \texttt{a[2].charAt(2) = 'a'} \]
Step 3: Combine the output.
The complete statement is: \[ \texttt{a[1].charAt(1) + "*" + a[2].charAt(2)} \]
So it becomes: \[ \texttt{'d' + "*" + 'a'} \]
This prints: \[ \texttt{d*a} \]
In the given options, this corresponds to d * a.
Step 4: Conclusion.
Therefore, the output of the statement is d * a.
Final Answer: d * a. Quick Tip: In Java strings, indexing starts from 0. Also, \texttt{charAt(n)} gives the character at position \texttt{n}, so always count from 0 carefully.
Which of the following String methods returns a negative value?
View Solution
Step 1: Understand what each String method returns.
In Java, different \texttt{String methods return different types of values. Some methods return a number, some return a character, and some return a boolean value. To answer this question, we need to identify which method can return a negative integer value.
Step 2: Analyze each method one by one.
(A) \texttt{length()}: This method returns the number of characters in a string. Since the length of a string can never be negative, it does not return a negative value.
(B) \texttt{equals()}: This method compares two strings and returns either \texttt{true or \texttt{false. It does not return any numeric value.
(C) \texttt{compareTo()}: This method compares two strings lexicographically. It can return:
a negative value if the first string comes before the second string,
zero if both strings are equal,
a positive value if the first string comes after the second string.
So, this method can definitely return a negative value.
(D) \texttt{charAt()}: This method returns the character present at a specified index in the string. It returns a character, not a negative number.
Step 3: Focus on \texttt{compareTo().
Suppose we compare: \[ \texttt{"Apple".compareTo("Banana")} \]
Since \texttt{"Apple" comes before \texttt{"Banana" in dictionary order, the result will be a negative value.
This shows clearly that \texttt{compareTo() is the method that can return a negative value.
Step 4: Conclusion.
Therefore, among all the given String methods, the one that returns a negative value is \texttt{compareTo().
Final Answer: compareTo(). Quick Tip: Remember: \texttt{compareTo()} returns \textbf{negative}, \textbf{zero}, or \textbf{positive} depending on dictionary order of strings. It is commonly used for lexicographical comparison.
An array with 3 elements is arranged in ascending order as follows:
Name the technique used:

View Solution
Step 1: Observe the sequence of swaps carefully.
The given array changes as follows: \[ [4 \quad 1 \quad 3] \rightarrow [1 \quad 4 \quad 3] \rightarrow [1 \quad 3 \quad 4] \]
In the first step, the adjacent elements \(4\) and \(1\) are compared and swapped because \(4 > 1\).
In the second step, the adjacent elements \(4\) and \(3\) are compared and swapped because \(4 > 3\).
So, the array gets sorted by repeatedly comparing and swapping adjacent elements.
Step 2: Recall the idea of Bubble Sort.
Bubble sort is a sorting technique in which adjacent elements are compared one by one, and if they are in the wrong order, they are swapped. In each pass, the largest element gradually moves toward the end of the array, just like a bubble rising upward.
Here, \(4\) first moves one position to the right and then again to the right until it reaches its correct place: \[ [4 \quad 1 \quad 3] \rightarrow [1 \quad 4 \quad 3] \rightarrow [1 \quad 3 \quad 4] \]
This exactly matches the working of Bubble sort.
Step 3: Compare with the other options.
(A) Bubble sort: Correct, because adjacent elements are swapped repeatedly.
(B) Linear Search: Incorrect, because linear search is used for finding an element, not sorting.
(C) Selection sort: Incorrect, because selection sort selects the minimum element and places it in the correct position, rather than swapping adjacent elements repeatedly.
(D) Binary Search: Incorrect, because binary search is a searching method used on sorted arrays, not a sorting technique.
Step 4: Conclusion.
Since the array is sorted by comparing and swapping neighboring elements step by step, the technique used is Bubble sort.
Final Answer: Bubble sort. Quick Tip: In \textbf{Bubble sort}, adjacent elements are compared and swapped repeatedly. If you see the largest element moving step by step toward the end, it is usually Bubble sort.
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?
View Solution
Step 1: Find the total number of elements in the two-dimensional array.
The question says that the sales data of \(5\) salesmen and \(5\) products is stored in a two-dimensional array. This means the array has: \[ 5 \times 5 = 25 \]
elements in total.
So, the array contains \(25\) integer values.
Step 2: Recall the memory occupied by one integer.
In Java, an int data type occupies \(4\) bytes of memory.
Therefore, each element of the array will take: \[ 4 bytes \]
Step 3: Calculate the total memory occupied.
Since there are \(25\) integer elements, total memory occupied by the array is: \[ 25 \times 4 = 100 \]
bytes.
Step 4: Match the answer with the given options.
(A) 25: Incorrect, this is only the number of elements.
(B) 200: Incorrect.
(C) 50: Incorrect.
(D) 100: Correct.
Hence, the array occupies 100 bytes.
Final Answer: \(100\) bytes. Quick Tip: For array memory questions, first find the total number of elements, then multiply by the size of one element. For an \textbf{int} in Java, always use \(4\) bytes.
Assertion (A): The \texttt{substring()} method modifies the original String.
Reason (R): The \texttt{substring()} method can extract part of a String from a specific index.
View Solution
Step 1: Understand the Assertion.
The assertion says that the \texttt{substring() method modifies the original String. In Java, Strings are immutable, which means once a String is created, its original content cannot be changed. Any method like \texttt{substring() does not alter the original String. Instead, it returns a new String containing the required part. Therefore, the Assertion is false.
Step 2: Understand the Reason.
The reason says that the \texttt{substring() method can extract part of a String from a specific index. This statement is correct. For example, if we write: \[ \texttt{"COMPUTER".substring(3)} \]
it returns the part of the String starting from index 3 till the end. So, the Reason is true.
Step 3: Check the relation between Assertion and Reason.
Although the Reason is true, it does not support the Assertion. The method \texttt{substring() only extracts a part of the String and returns it as a new String. It does not modify the original String. Hence, the Assertion is false, while the Reason is true.
Step 4: Conclusion.
So, the correct option is: \[ \textbf{(B) (A) is false and (R) is true} \]
because \texttt{substring() extracts part of a String, but it does not change the original String.
Final Answer: (A) is false and (R) is true. Quick Tip: In Java, Strings are immutable. Methods like \texttt{substring()}, \texttt{concat()}, and \texttt{replace()} return new Strings instead of changing the original one.
In constructor overloading all constructors should have the same class but with a different set of ________.
View Solution
Step 1: Understand constructor overloading.
Constructor overloading means defining more than one constructor in the same class. All these constructors have the same class name, because a constructor must always have the same name as the class. However, they must differ from each other in the list of arguments they accept.
Step 2: Recall the rule for overloading.
In Java, overloading is achieved when methods or constructors have the same name but a different parameter list. The difference may be in:
number of parameters,
type of parameters,
or order of parameters.
So, for constructor overloading, the constructors must be distinguished by their parameters.
Step 3: Compare the given options.
(A) Access specifiers: Incorrect. Constructors may have different access specifiers, but this is not the basis of overloading.
(B) Classes: Incorrect. Constructor overloading happens within the same class, not different classes.
(C) Return type: Incorrect. Constructors do not have any return type.
(D) Parameters: Correct. Overloaded constructors must differ in their parameter lists.
Step 4: Conclusion.
Therefore, in constructor overloading, all constructors belong to the same class but have a different set of parameters.
Final Answer: Parameters. Quick Tip: Constructors never have a return type. If you see the word \textbf{overloading}, immediately think of \textbf{same name but different parameters}.
Rewrite the following program segment using a for loop.
Given program segment:
int a = 5, b = 10;
while (b > 0)
\{}
b -= 2;
\}
System.out.println(a * b);
View Solution
Step 1: Understand the working of the while loop.
The variable \( b \) is initially assigned the value \( 10 \). The loop continues as long as \( b > 0 \). In each iteration, the value of \( b \) is decreased by \( 2 \).
Step 2: Identify the three parts needed in a for loop.
A \texttt{for loop contains initialization, condition, and updation in one statement. Here:
Initialization: \( b = 10 \)
Condition: \( b > 0 \)
Updation: \( b -= 2 \)
Step 3: Rewrite the loop in for loop form.
So, the equivalent \texttt{for loop becomes:
\[ \begin{array}{l} \texttt{int a = 5, b = 10;}
\texttt{for (; b > 0; b -= 2)}
\texttt{\{}
\texttt{\}}
\texttt{System.out.println(a * b);} \end{array} \]
Step 4: Write the final rewritten program.
Hence, the required program segment using a \texttt{for loop is:
\[ \begin{array}{l} \texttt{int a = 5, b = 10;}
\texttt{for (; b > 0; b -= 2)}
\texttt{\{}
\texttt{\}}
\texttt{System.out.println(a * b);} \end{array} \] Quick Tip: To convert a \texttt{while} loop into a \texttt{for} loop, place the initialization, condition, and update parts inside the \texttt{for} statement in the same order.
Evaluate the Java expression:
\[ x = a * b % (++c) + (++a) + (--b); \]
if \(a = 7\), \(b = 8\), \(c = 2\).
View Solution
Step 1: Write the given values.
We are given:
\[ a = 7, \quad b = 8, \quad c = 2 \]
Step 2: Apply the pre-increment and pre-decrement operators.
In Java, \(++c\) means first increase \(c\) by \(1\), then use its value. So:
\[ ++c = 3 \]
Similarly, \(++a = 8\) and \(--b = 7\).
Step 3: Substitute the updated values into the expression.
Now the expression becomes:
\[ x = 7 * 8 % 3 + 8 + 7 \]
Step 4: Perform multiplication and modulus.
First multiply:
\[ 7 * 8 = 56 \]
Now find modulus:
\[ 56 % 3 = 2 \]
Step 5: Add the remaining terms.
Now,
\[ x = 2 + 8 + 7 \] \[ x = 17 \] Quick Tip: In Java, pre-increment \((++a)\) and pre-decrement \((--b)\) change the value first, then use it in the expression.
Write the Java expression to find the sum of cube root of \(x\) and the absolute value of \(y\).
View Solution
Step 1: Identify the required mathematical operations.
We need two operations here:
\[ cube root of x \]
and
\[ absolute value of y \]
Step 2: Recall the Java methods.
In Java, the cube root is found using \texttt{Math.cbrt(x) and the absolute value is found using \texttt{Math.abs(y).
Step 3: Add both expressions.
Therefore, the required Java expression is:
\[ \texttt{Math.cbrt(x) + Math.abs(y)} \] Quick Tip: Use \texttt{Math.cbrt()} for cube root and \texttt{Math.abs()} for absolute value in Java.
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 \texttt{idStatus} and print it.
View Solution
Step 1: Understand the condition.
The user is eligible only when age is greater than \(10\). So the condition is:
\[ \texttt{age > 10} \]
Step 2: Use the ternary operator.
A ternary operator in Java has the form:
\[ \texttt{condition ? value1 : value2} \]
If the condition is true, the first message is stored; otherwise, the second message is stored.
Step 3: Write the required Java code.
The required code is:
\texttt{String idStatus = (age > 10) ? "Eligible" : "Not Eligible";
\texttt{System.out.println(idStatus);
Step 4: Explain the result.
If the age is more than \(10\), the program prints \texttt{"Eligible". Otherwise, it prints \texttt{"Not Eligible".
Quick Tip: The ternary operator is a short form of if-else. It is useful when you need to assign one of two values based on a condition.
Give the output of the following program segment:
String S = "GRACIOUS".substring(4);
System.out.println(S);
System.out.println("GLAMOROUS".endsWith(S));
View Solution
Step 1: Find the value of \texttt{S.
The string is:
\[ \texttt{"GRACIOUS"} \]
Its characters with index positions are:
\[ G(0)\; R(1)\; A(2)\; C(3)\; I(4)\; O(5)\; U(6)\; S(7) \]
So, \texttt{substring(4) gives the part of the string starting from index \(4\):
\[ \texttt{"IOUS"} \]
Therefore,
\[ S = \texttt{"IOUS"} \]
Step 2: Print the first output.
The first statement prints:
\[ \texttt{IOUS} \]
Step 3: Check the \texttt{endsWith() condition.
Now we check whether \texttt{"GLAMOROUS" ends with \texttt{"IOUS".
The ending part of \texttt{"GLAMOROUS" is \texttt{"ROUS", not \texttt{"IOUS".
So the result is:
\[ \texttt{false} \]
Step 4: Write the final output.
Hence, the output is:
\texttt{IOUS
\texttt{false
Quick Tip: In Java, \texttt{substring(n)} returns the string starting from index \(n\), and \texttt{endsWith()} checks whether a string ends with the given suffix.
Give the output of the following program segment and mention how many times the loop is executed.
int K = 1;
do
{
K += 2;
System.out.println(K);
while (K < 6);
View Solution
Step 1: Write the initial value of \(K\).
Initially,
\[ K = 1 \]
Step 2: Understand the working of the \texttt{do-while loop.
In a \texttt{do-while loop, the statements inside the loop are executed first, and only after that the condition is checked. So the loop will run at least one time.
Step 3: Execute the loop step by step.
First iteration:
\[ K = 1 + 2 = 3 \]
So, \(3\) is printed. Since \(3 \leq 6\), the loop continues.
Second iteration:
\[ K = 3 + 2 = 5 \]
So, \(5\) is printed. Since \(5 \leq 6\), the loop continues.
Third iteration:
\[ K = 5 + 2 = 7 \]
So, \(7\) is printed. Now \(7 \leq 6\) is false, so the loop stops.
Step 4: Write the output.
Hence, the output is:
\texttt{3
\texttt{5
\texttt{7
Step 5: Count the number of loop executions.
The loop is executed \(3\) times.
Quick Tip: A \texttt{do-while} loop always executes at least once because the condition is checked after the loop body runs.
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\)]
{int P, n = 5, f = 0;
for (P = n; P > 0; P--)
{
f *= P;
System.out.println(f);
View Solution
Step 1: Recall how factorial is calculated.
The factorial of a number is obtained by multiplying all positive integers from that number down to \(1\). For example,
\[ 5! = 5 \times 4 \times 3 \times 2 \times 1 = 120 \]
Step 2: Identify the mistake in the given program.
In the given code, the variable \texttt{f is initialized as \texttt{0. Then the statement \texttt{f *= P means:
\[ f = f \times P \]
Since \(f\) starts with \(0\), every multiplication will remain \(0\). Therefore, the program will not calculate the factorial correctly.
Step 3: Write the correct initialization.
To calculate factorial, the multiplication should start from \(1\), not \(0\). So the correct initialization is:
\texttt{int P, n = 5, f = 1;
Step 4: Trace the corrected program.
Now the loop works as follows:
\[ f = 1 \times 5 = 5 \] \[ f = 5 \times 4 = 20 \] \[ f = 20 \times 3 = 60 \] \[ f = 60 \times 2 = 120 \] \[ f = 120 \times 1 = 120 \]
Step 5: Write the corrected program and answer.
The corrected program is:
\texttt{int P, n = 5, f = 1;
\texttt{for (P = n; P > 0; P--)
\texttt{\{
\texttt{\ \ \ \ f *= P;
\texttt{\
\texttt{System.out.println(f);
So, the output will be:
\[ \boxed{120} \] Quick Tip: Whenever repeated multiplication is needed, initialize the result variable with \(1\), because multiplying by \(0\) always gives \(0\).
For the array U[][] = {{4, 5}, {7, 2}, {19, 4}, {7, 43}}}, find the maximum element and the index of the minimum element.
View Solution
Step 1: Write all the elements of the array.
The given 2D array is:
\[ \begin{bmatrix} 4 & 5
7 & 2
19 & 4
7 & 43 \end{bmatrix} \]
Step 2: Find the maximum element.
Now compare all the elements:
\[ 4,\ 5,\ 7,\ 2,\ 19,\ 4,\ 7,\ 43 \]
The greatest value among these is:
\[ 43 \]
Step 3: Find the minimum element.
The smallest value in the array is:
\[ 2 \]
Step 4: Find the index of the minimum element.
In Java, array indexing starts from \(0\).
The element \(2\) is present in the second row and second column, so its index is:
\[ [1][1] \]
Step 5: State the final answer.
Therefore:
\[ \boxed{Maximum element = 43} \]
and
\[ \boxed{Index of minimum element = [1][1]} \] Quick Tip: In Java 2D arrays, indexing starts from \(0\). So the first row is row \(0\) and the first column is column \(0\).
Write the statement that swaps the first element and the second element using the third variable. Fill in the blanks.
View Solution
Step 1: Understand the concept of swapping.
To swap two values, we use a third temporary variable to store one value so that it is not lost during assignment.
Step 2: Store the first element in the third variable.
First, store the value of the first element in the temporary variable:
\[ \texttt{temp = first;} \]
Step 3: Copy the second element into the first.
Now assign the value of the second element to the first element:
\[ \texttt{first = second;} \]
Step 4: Copy the temporary value into the second.
Finally, assign the stored value from the temporary variable to the second element:
\[ \texttt{second = temp;} \]
Step 5: Write the final statements.
Therefore, the required swapping statements are:
\texttt{temp = first;
\texttt{first = second;
\texttt{second = temp;
Quick Tip: While swapping two variables, always use a temporary variable if you want to avoid losing one of the values during assignment.
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 using the following estimation table.
View Solution
Step 1: Declare the class and member variables.
First, we define a class named \texttt{StepTracker. Inside this class, we declare the given data members: \texttt{name, \texttt{sw, \texttt{cb, and \texttt{km. These variables will store the user's name, number of steps walked, calories burned, and distance covered respectively.
Step 2: Write the \texttt{accept() method.
In this method, we use the \texttt{Scanner class to take input from the user. The user's name is stored in \texttt{name, and the total number of steps walked is stored in \texttt{sw.
Step 3: Write the \texttt{calculate() method.
This method is used to calculate the values of calories burned and distance walked. Since the estimation table is not fully visible in the image, the exact calculation formulas are not available here. So, placeholders are written below where the actual formulas from the table should be inserted.
Step 4: Write the program structure.
The required class structure in Java can be written as follows:
\begin{verbatim
import java.util.Scanner;
class StepTracker
{
String name;
int sw;
double cb;
double km;
void accept()
{
Scanner sc = new Scanner(System.in);
System.out.print("Enter name: ");
name = sc.nextLine();
System.out.print("Enter steps walked: ");
sw = sc.nextInt();
void calculate()
{
// Insert the exact formulas here according to the estimation table
// Example:
// cb = ...
// km = ...
void display()
{
System.out.println("Name = " + name);
System.out.println("Steps Walked = " + sw);
System.out.println("Calories Burned = " + cb);
System.out.println("Distance Walked = " + km + " km");
\end{verbatim
Step 5: Final conclusion.
Thus, the class \texttt{StepTracker is defined with the required member variables and methods. The exact formulas for \texttt{cb and \texttt{km should be filled according to the estimation table shown in the complete question.
Quick Tip: Whenever a class-based Java question is asked, first identify the member variables, then write input methods, calculation methods, and finally an output method for proper structure.
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.
![]()
View Solution
Step 1: Understand the requirement of the question.
In this question, we have to store the designations of \(100\) employees in a one-dimensional array. After storing all the designations, we need to accept one designation from the user and count how many times that designation appears in the array. Finally, we print that total count.
Step 2: Declare the required variables and array.
We need a string array to store the designations of \(100\) employees. We also need one variable to store the designation entered by the user for searching, and one counter variable to count the number of matches.
Step 3: Accept the designations of 100 employees.
Using a loop, we input all \(100\) designations one by one and store them in the array. Since designations are words such as \texttt{Manager, \texttt{Trainee, \texttt{Director, etc., we use a \texttt{String array.
Step 4: Search the given designation in the array.
After taking the input designation to be searched, we traverse the array again. Every time the entered designation matches an element of the array, we increase the counter by \(1\). For string comparison in Java, we use the \texttt{equalsIgnoreCase() method so that the comparison works properly even if the user enters the designation in a different letter case.
Step 5: Display the final result.
At the end of the loop, the counter contains the total number of employees having the required designation. This value is then printed as the output.
Step 6: Write the complete Java program.
The required Java program is:
\begin{verbatim
import java.util.Scanner;
class EmployeeDesignation
{
public static void main(String args[])
{
Scanner sc = new Scanner(System.in);
String desig[] = new String[100];
String search;
int i, count = 0;
for(i = 0; i < 100; i++)
{
System.out.print("Enter designation of employee " + (i + 1) + ": ");
desig[i] = sc.nextLine();
System.out.print("Enter designation to be searched: ");
search = sc.nextLine();
for(i = 0; i < 100; i++)
{
if(desig[i].equalsIgnoreCase(search))
{
count++;
System.out.println("Total number of employees = " + count);
\end{verbatim
Step 7: Explain the example given in the question.
For example, if the designations stored are \texttt{Trainee, \texttt{Manager, \texttt{Chef, \texttt{Manager, \texttt{Director, \texttt{Manager and the input designation is \texttt{Manager, then the word \texttt{Manager appears \(3\) times. Therefore, the output will be \(3\).
Quick Tip: When comparing strings in Java, always use \texttt{equals()} or \texttt{equalsIgnoreCase()} instead of \(==\), because \(==\) compares references, not actual string values.
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.
View Solution
Step 1: Understand the concept of a sparse matrix.
A sparse matrix is a matrix in which the number of zero elements is greater than the number of non-zero elements. Here, we have to accept a \( 4 \times 5 \) integer matrix from the user, count the number of zero and non-zero elements, and then decide whether the matrix is sparse or not.
Step 2: Declare the required array and variables.
We need a two-dimensional integer array of size \( 4 \times 5 \) to store the matrix elements. We also need two counter variables: one to count zero elements and another to count non-zero elements.
Step 3: Accept the matrix elements from the user.
Using nested loops, we can input all the elements of the matrix row by row. Since the matrix has \( 4 \) rows and \( 5 \) columns, the outer loop will run \( 4 \) times and the inner loop will run \( 5 \) times.
Step 4: Count zero and non-zero elements.
While traversing the matrix, each element is checked. If the element is equal to \( 0 \), then the zero counter is increased. Otherwise, the non-zero counter is increased. In this way, at the end of traversal, we get the total number of zero and non-zero elements.
Step 5: Compare the two counts.
After counting, we compare the total number of zero elements with the total number of non-zero elements. If the number of zero elements is greater, then the matrix is a sparse matrix. Otherwise, it is not a sparse matrix.
Step 6: Write the complete Java program.
The required Java program is:
\begin{verbatim
import java.util.Scanner;
class SparseMatrix
{
public static void main(String args[])
{
Scanner sc = new Scanner(System.in);
int a[][] = new int[4][5];
int i, j;
int zero = 0, nonzero = 0;
System.out.println("Enter the elements of the matrix:");
for(i = 0; i < 4; i++)
{
for(j = 0; j < 5; j++)
{
a[i][j] = sc.nextInt();
if(a[i][j] == 0)
zero++;
else
nonzero++;
System.out.println("Number of zero elements = " + zero);
System.out.println("Number of non-zero elements = " + nonzero);
if(zero > nonzero)
System.out.println("It is a Sparse Matrix.");
else
System.out.println("It is not a Sparse Matrix.");
\end{verbatim
Step 7: Conclude the logic of the program.
Thus, the program first stores all elements of the \( 4 \times 5 \) matrix, then counts the zero and non-zero values, and finally checks whether the matrix satisfies the condition of a sparse matrix. If zero elements are more than non-zero elements, the appropriate message is displayed.
Quick Tip: For matrix-based questions, always use nested loops. One loop is used for rows and the other for columns. While traversing, you can perform counting, checking, or other operations easily.








Comments