0% found this document useful (0 votes)
8 views2 pages

Computer Application Test Class X

The document is a morning test for Class X students at The Punjab Public School, Nabha, focusing on Computer Applications. It includes multiple-choice questions, output-based questions, and programming tasks related to arrays and classes in Java. The test assesses students' understanding of Java syntax, string manipulation, and object-oriented programming concepts.

Uploaded by

Raj Kumar
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views2 pages

Computer Application Test Class X

The document is a morning test for Class X students at The Punjab Public School, Nabha, focusing on Computer Applications. It includes multiple-choice questions, output-based questions, and programming tasks related to arrays and classes in Java. The test assesses students' understanding of Java syntax, string manipulation, and object-oriented programming concepts.

Uploaded by

Raj Kumar
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

THE PUNJAB PUBLIC SCHOOL, NABHA

Morning Test 2025


27th November, 2025

SUBJECT: COMPUTER APPLICATION CLASS: X


TIME: 40 Minutes M.M.: 20

1. MCQ’s: (5x1=5)

1. Which of the following is the correct 2. What is the index of the first element
way to declare an array in Java? of an array?
A. int arr[]; A. 1
B. int arr; B. –1
C. array arr[]; C. 0
D. int arr()[]; D. Depends on size

3. A string is a collection of: 4. Which method compares two


A. Numbers strings?
B. Characters A. equals()
C. Arrays B. compare()
D. Objects C. compareTo()
D. Both A and C

5. Which method compares two strings


ignoring case?
A. equals()
B. compareTo()
C. equalsIgnoreCase()
D. compareIgnoreCase()

2. Output-Based Questions (5x1=5)

1. 2.
int a[] = {10, 20, 30, 40}; int a[] = {3, 6, 9, 12};
for(int i = 0; i < 4; i += 2) int sum = 0;
[Link](a[i] + " "); for(int i = 0; i < [Link]; i++)
sum += a[i];
[Link](sum);
3. 4.
int a[] = {4, 8, 12, 16}; String s = "India";
[Link]([Link]); [Link]([Link]('a'));
5.
String s = "abc";
s = [Link]("123");
[Link](s);

Question/answers (2x5=10)

Q1. Define a class to accept values in integer array of size 10. Sort them in an
ascending order using Bubble sort technique.

Q2. Design a class with the following specifications:


Class name: Employee
Member variables: (Use appropriate data types)

ename — name of employee

deptno — department number

salary — monthly salary

grade — grade assigned

Member methods:
1. void input()

Accept ename, deptno, and salary using Scanner class.

2. void assignGrade()

Assign grade based on the following criteria:

Salary (₹) Grade


>= 80,000 A – Excellent
>= 50,000 and < 80,000 B – Very Good
>= 25,000 and < 50,000 C – Good
< 25,000 D – Needs Improvement
3. void display()
Display the employee name, department number, salary, and grade assigned.

In main(): Create an object of Employee class and call input(), assignGrade(), and
display().

Common questions

Powered by AI

The 'equalsIgnoreCase()' method is used in Java to perform string comparisons without considering case sensitivity, making it ideal in scenarios where the equivalency of strings should not be affected by letter casing, such as user input validation. For example, when comparing user responses in different casings like 'Yes', 'YES', or 'yes', 'equalsIgnoreCase()' would treat them as equal, whereas 'equals()' would not. This feature promotes usability and flexibility in applications where user input or data interchanges occur with varied string casing .

The implementation of the bubble sort technique in Java is a great example of using loops and conditionals to solve a problem. It involves iterating over an integer array multiple times using nested loops. The outer loop ensures that passes are made over the entire array, while the inner loop compares adjacent elements and swaps them if they are in the wrong order, relying on a conditional (if statement) to check this condition. This repeated comparison and swapping illustrated through loops, showcases how fundamental programming constructs can be applied to execute precise data sorting algorithms .

The 'compareTo()' method in Java is used to compare two strings lexicographically, based on the Unicode value of each character in the strings. If the two strings are equal, it returns 0; if the first string is lexicographically less, it returns a negative integer; and if it is greater, it returns a positive integer. The 'equals()' method, on the other hand, checks for equality based on content and returns a boolean value—true if the strings have the same sequence of characters, and false otherwise .

The 'indexOf()' method is particularly useful for string handling in Java as it provides the capability to locate the first appearance of a specified character in a string. This functionality is crucial when parsing strings to identify delimiters, formatting specific substrings, or implementing routine operations like searching. The efficiency in locating and returning either the index of the character or -1 if not found, aids in dynamic text processing and manipulation, which are common requirements in software development .

The logic for calculating the sum of an integer array in Java, as shown in the example, involves initializing a sum variable to zero and then iterating over the entire array using a for-loop. During each iteration, the current array element is added to the sum variable, progressively building the total sum. This approach efficiently processes the array in a linear fashion, illustrating a straightforward application of iteration to perform accumulative operations over data structures like arrays .

The design of the 'Employee' class exemplifies object-oriented programming principles such as encapsulation, abstraction, and modularity. Encapsulation is demonstrated through the use of member variables and methods that are bundled together, providing a structure to interact with employee data. Abstraction is applied by hiding complex logic within methods like input() and assignGrade(), allowing users to interact with these methods without needing to understand their inner workings. Furthermore, the separation of processes such as input, computation of grade, and display adheres to modularity, promoting reusable and manageable code .

Arrays in Java provide a convenient way to store multiple values of the same type that are easily accessible by index, allowing for efficient data organization and retrieval. Key advantages include reduced lines of code for handling multiples of the same data type and constant-time access to elements. However, arrays in Java have a fixed size after declaration, which limits their flexibility when applications require adding or removing elements frequently. This limitation can lead to inefficient memory usage or require complex workarounds, such as copying old arrays into new larger arrays, reducing performance .

The 'indexOf()' method in Java is crucial for string manipulation as it allows developers to identify the position of a character or a substring within a string. This method can be used to locate specific data points or to verify if a character/substring exists within a string, returning the index of the first occurrence or -1 if it is not found. Such functionality is significant in applications where pattern recognition or substring extraction is necessary, thereby enabling more dynamic and data-driven applications .

The output sequence from the loop demonstrated by 'for(int i = 0; i < 4; i += 2)' shows the effectiveness of control structures to navigate and select elements within an array in Java. The loop begins at index 0, processes the element, then incrementally skips to every third index, effectively processing non-consecutive elements such as in the pattern {10, 30}. This showcases the flexibility in using incrementation (i += 2) for selective traversal, rather than default linear or consecutive iteration, permitting specific control over array processing .

In Java, the 'concat()' method and the '+' operator both serve to concatenate, or join, strings, but they do so in distinct manners. The 'concat()' method strictly concatenates two strings and throws a NullPointerException if the argument is null, highlighting its method-oriented operation. The '+' operator is overloaded in Java and can act as a string concatenation tool that associates other data types, converting them to strings, and can handle null references more leniently by treating them as 'null'. The 'concat()' method may lead to more explicit string manipulation, aiding in scenarios where method chaining or explicit null handling is preferable .

You might also like