0% found this document useful (0 votes)
211 views9 pages

Triangle Area Calculation Error

The document is an examination paper for Class X Computer Applications, consisting of multiple-choice questions and programming tasks. It covers various Java concepts, including data types, methods, and control structures, as well as practical programming assignments. The paper is divided into two sections, with Section A focusing on theoretical questions and Section B requiring coding solutions.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
211 views9 pages

Triangle Area Calculation Error

The document is an examination paper for Class X Computer Applications, consisting of multiple-choice questions and programming tasks. It covers various Java concepts, including data types, methods, and control structures, as well as practical programming assignments. The paper is divided into two sections, with Section A focusing on theoretical questions and Section B requiring coding solutions.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

CLASS X

COMPUTER APPLICATIONS

Maximum Marks: 100

Time allowed: one hour

SECTION A
(Attempt all questions from this Section.)
Question 1 (1 × 20 = 20)
Choose the correct answers to the questions from the given options.
(Do not copy the question, write the correct answers only.)

(i)

Name the feature of java depicted in the above picture.


(a) Encapsulation
(b) Inheritance
(c) Abstraction
(d) Polymorphism
(ii) A fall through is a
(a) type of error
(b) code
(c) variable
(d) loop

1
(iii) The result of dividing by zero in java is

(a) Error

(b) Exception

(c) Infinite

(d) None
(iv) When a composite data type is converted to a corresponding primitive data type,
is called:
(a) Boxing

(b) Unboxing

(c) explicit type conversion

(d) implicit type conversion


(v) The number of bytes occupied by a char array of 20 elements.

(a) 20 bytes

(b) 40 bytes

(c) 80 bytes

(d) 160 bytes


(vi) A variable that is declared within the class but outside constructors or block is
called as

(a) Instance variable

(b) Class variable

(c) Local variable

(d) Argument variable


(vii) Find the output of the following code:
int a=10;
[Link](++a);

(a) 10

(b) 9

(c) 11

(d) code error

2
(viii) The output of [Link](8.5) + [Link](-4.3) is:

(a) 14.0

(b) 4.0

(c) 14

(d) 4
(ix) Implicit type conversion is also known as
(a) coercion

(b) type casting

(c) dynamic casting

(d) static conversion


(x) Java statement to access the nth element of an array is:

(a) X[n]

(b) X[n+1]

(c) X[n-1]

(d) X[2n]
(xi) Which of the following functions is used to check whether a given character is a
tab

(a) isTab()

(b) isTabSpace()

(c) isSpace()
(d) isWhitespace()
(xii) Cell numbers of a dimensional array are known as …..

(a) packets

(b) blocks

(c) subscripts

(d) compartments

3
(xiii) Name the package that contains wrapper classes:

(a) [Link]

(b) [Link]

(c) java .io

(d) [Link]
(xiv) The technique in which the change in the formal parameter is reflected in the
actual parameter is known as …..
(a) call by value

(b) call by reference

(c) call by argument

(d) call by address


(xv) Which of the following methods does not return an int value ?
(a) compareTo()

(b) indexOf()

(c) endsWith()

(d) none
(xvi) In the following program code, what is the process involved?
int x=12;
Integer y = x;
(a) boxing

(b) auto boxing

(c) packaging

(d) unboxing
(xvii) Assertion(A): The indexOf() method is used for searching for the first
occurrence of a character in a string.
Reason(R): The indexOf() and lastIndexOf() methods do the same
function.

(a) Both Assertion (A) and Reason (R) are true and Reason (R) is a correct
explanation of Assertion (A)
(b) Both Assertion (A) and Reason (R) are true and Reason (R) is not a
correct explanation of Assertion(A)
(c) Assertion (A) is true and Reason (R) is false

(d) Assertion (A) is false and Reason (R) is true

4
(xviii) Read the following text, and choose the correct answer:

A class encapsulate Data Members that contains the information necessary to


represent the class and Member methods that perform operations on the data
member.
What does a class encapsulate?

(a) Information and operation

(b) Data members and Member methods

(c) Data members and information

(d) Member methods and operation


(xix) Assertion(A): call by value is known as pure method

Reason(R): The original value of variable does not change as operation is


performed on copied values.
(a) Both Assertion (A) and Reason (R) are true and Reason (R) is a correct
explanation of Assertion (A)
(b) Both Assertion (A) and Reason (R) are true and Reason (R) is not a
correct explanation of Assertion (A)
(c) Assertion (A) is false and Reason (R) is true

(d) Assertion (A) is false and Reason (R) is true


(xx) String in java is a
(a) object

(b) character array

(c) class

(d) variable

Question 2

(i) State the output of the following program segment: [2]


String s = “Internet of Things”;
int n=[Link]();
[Link]([Link]([Link](6,n)));
[Link]([Link](3) = = [Link](7));
(ii) Evaluate the expression when the value of x = 5: [2]
x += x ++ + ++ x + x
(iii) The following code segment should print “You can go out” if you have done [2]
your homework (dh) and cleaned your room(cr). However, the code has errors.

5
Fix the code so that it compiles and runs correctly.
boolean dh = True; boolean cr= true; if (dh && cr)
[Link]("You cannot go out"); else
[Link]("You can go out");
(iv) Sam executes the following program segment and the answer displayed is zero [2]
irrespective of any non zero values are given. Name the error. How the program
can be modified to get the correct answer?
void triangle(double b, double h)
{ double a; a = ½ * b * h;
[Link](“Area=”+a); }
(v) How many times will the following loop execute? What value will be returned? [2]
int x=2;
int y=50; do{
++x;
y-=x++;
}
while(x<=10); return y;
(vi) Write the output of the following String methods: [2]
(a) "ARTIFICIAL ".indexOf('I' )
(b) “DOG and PUPPY”. trim().length()
(vii) Name any two jump statements. [2]

(viii) Predict the output of the following code snippet: String a="20"; [2]
String b="23";
int p=[Link](a); int q=[Link](b); [Link](a+"*"+b);
(ix) When there is no explicit initialization, what are the default values set for [2]
variables in the following cases?
(a) Integer variable
(b) String variable

(x) int n[ ] = {1,2,3,5,7,8,13,16}; [2]


What are the values of x and y?

x = [Link](n[3] , n[2]);
y = [Link](n[5] + n[0])

6
SECTION B(4×15=60)

(Answer any four questions from this Section.)


Question 3
Design a class name EShop with the following description :
Instance variables/ Data members :
String name – To store the name of the customer
long mobno – To store the mobile number of the customer
double cost – To store the cost of the items purchased
double dis – To store the discount amount
double amount – To store the amount to be paid after discount
Member methods: –
EShop() – default constructor to initialize data members
void input() – To input customer name, mobile number, cost
void calculate() – To calculate discount on the cost of purchased items, based on following criteria

Discount (in
Cost
percentage)

Less than or equal to ₹ 10000 5%

More than ₹ 10000 and less than or equal to ₹


10%
20000

More than ₹ 20000 and less than or equal to ₹


15%
35000

More than ₹ 35000 20%

void display() – To display customer name, mobile number, amount to be paid after discount
Write a main method to create an object of the class and call the above member methods.

7
Question 4
Write a program to input a number and print whether the number is a special number or not.
(A number is. said to be a special number, if the sum of the factorial of the digits of the number is
same as the original number).
Example: 145 is a special number, because 1!+4!+5! = 1 + 24 + 120 = 145 (Where! stands for
factorial of the number and the factorial value of a number is the product of all integers from 1 to
that number, example 5! = 1*2*3*4*5 = 120).

Question 5
Write a Java program to initialize a square matrix of order 4×4 to store integers. Display the
matrix data in the format of matrix. Also check whether the given matrix is a UNIQUE matrix of
not.

A UNIQUE matrix is a matrix whose sum of left diagonal elements is equal to the sum of right
disgonal elements.

Question 6

Write a program to input twenty names in an array. Arrange these names in ascending order of
letters, using the bubble sort technique.
Sample Input:
Rohit, Devesh, Indrani, Shivangi, Himanshu, Rishi, Piyush, Deepak, Abhishek, Kunal, .....
Sample Output:
Abhishek, Deepak, Devesh, Himanshu, Indrani, Kunal, Piyush, Rishi, Rohit, Shivangi, .....

Question 7

Design a class to overload a function find ( ) as follows :


(i) void find (String str, char ch) – to find and print the frequency of a character in a string.
Example : *
Input:
str = “success”
ch = ‘s’ .
Output:
number of s present is = 3

(ii) void find(String si) – to find and display only vowels from string si, after converting it to lower
case.
Example:
Input:
s1 = “computer”
Output:
oue

Question 8

Write a program to initialize the Seven Wonders of the World along with their locations in two
different arrays. Search for a name of the country input by the user. If found, display the name of

8
the country along with its Wonder, otherwise display “Sorry Not Found!”.
Seven wonders — CHICHEN ITZA, CHRIST THE REDEEMER, TAJMAHAL, GREAT WALL
OF CHINA, MACHU PICCHU, PETRA, COLOSSEUM
Locations — MEXICO, BRAZIL, INDIA, CHINA, PERU, JORDAN, ITALY
Example — Country Name: INDIA Output: INDIA-TAJMAHAL
Country Name: USA Output: Sorry Not Found!

Common questions

Powered by AI

Bubble sort is a simple sorting algorithm that repeatedly steps through a list to be sorted, compares adjacent elements, and swaps them if they are in the wrong order. The pass through the list is repeated until no swaps are needed, indicating that the list is sorted. This process is critical for organizing data effectively as it ensures that user inputs, like unsorted names, are ordered in a way that supports efficient searching and retrieval operations. Despite its simplicity, bubble sort is primarily useful for educational purposes or small datasets due to its O(n^2) time complexity .

Coercion, or implicit type conversion, is the automatic conversion of one data type into another. It simplifies coding as programmers do not need to manually implement explicit conversions, which can streamline operations across different data types. However, its overuse can lead to unintended results, especially if there's a loss of precision in numeric conversions. Thus, understanding coercion is crucial for balancing convenience with functional accuracy in programming .

Encapsulation involves bundling the data (fields) and methods that operate on that data into a single unit or class, and restricting access to some of the object's components, which leads to enhanced security and reduces accidental data corruption. Abstraction, on the other hand, hides complex details by providing a simplified interface, allowing the programmer to handle complexity by focusing on higher-level objectives. Both paradigms contribute to code maintainability by promoting modular design, reducing dependencies, and facilitating changes or enhancements with minimal impact on existing code .

The 'indexOf()' method is used to find the first occurrence of a specified character or substring within a string, starting from the beginning of the string. Conversely, 'lastIndexOf()' searches backward from the end of the string to find the last occurrence. While both methods serve the purpose of locating positions within a string, 'indexOf()' is typically used when the first match is sought, whereas 'lastIndexOf()' is useful for finding where the last occurrence appears .

Data types in Java determine the amount of memory allocated to store variables. For instance, each 'char' occupies 2 bytes due to Java's use of Unicode to support international character sets. Thus, a 'char array' with 20 elements would occupy 40 bytes of memory. Understanding these specifications is crucial for writing memory-efficient programs, especially in resource-constrained environments .

'Call by value' refers to the mechanism where functions receive copies of the actual values passed into them, meaning modifications within the function do not affect the original values. This concept is closely related to immutability since the original value of a variable remains unchanged even though operations may be performed on its copy. Hence, call by value maintains the immutability of the original variable, ensuring its original state is preserved beyond the scope of the function .

'Boxing' in Java refers to the automatic conversion of primitive types to their corresponding wrapper class objects, while 'unboxing' is the reverse process. For example, 'Integer y = x;' where x is an int, involves 'autoboxing' as the int is converted to an Integer. These conversions help streamline operations that involve collections such as ArrayLists, which can only store object types, not primitives .

A default constructor initializes a class's instance variables with default values, ensuring that an object starts in a valid state. For example, in the class 'EShop', the default constructor could initialize instance variables like 'name', 'mobno', and 'cost' to default values, while member methods like 'input()', 'calculate()', and 'display()' provide mechanisms to update and utilize these variables. Together, they ensure that objects are properly initialized, and business logic is correctly implemented, fostering modular, clear, and maintainable code .

Java's exception handling mechanism allows developers to separate error handling code from regular code, promoting cleaner and more understandable programs. Unlike traditional error reporting that may use return codes or side effects, Java's try-catch-finally blocks, throw, and throws keywords provide a structured approach, ensuring errors are caught and managed appropriately without cluttering main logic streams. This leads to reliable error management, easier debugging, and more robust applications, significant advantages over less structured error handling techniques .

In Java, dividing an integer by zero results in an 'ArithmeticException', signifying improper operations as Java does not allow division by zero due to undefined results. For floating-point operations, dividing by zero yields 'Infinity' or '-Infinity' depending on the sign. These outcomes manifest Java's robust error handling, where the language interrupts execution with exceptions, ensuring that erroneous calculations do not pass silently .

You might also like