10 mock
10 mock
COMPUTER APPLICATION
Choose the correct answers to the questions from the given options
(Do not copy the question, write the correct option only.)
i)
ii) “Java compiled code (byte code) can run on any operating system” – Name the feature.
a) Robust and Secure
b) Platform independent
c) Multithreaded
d) Object Oriented
iv) The absence of which statement leads to fall through situation in switch case statement?
a) continue
b) break
c) System.exit(0)
d) Return
v) Assertion (A) :Non primitive data type is also referred to as Reference data type.
Reason (R) : They store data values with reference to the address or location.
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.
vi) Forcefully converting one data type to another type is called ______________.
a) Implicit type casting
b) Automatic type casting
c) Explicit type casting
Page 1 of 4
d) Force type casting
vii) Which of the following options returns by the CompareTo( ) function if two strings are
equal?
a) True
b) False
c) 0
d) 1
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.
Question 2.
ii) Evaluate the given expression when the value of k=8, m=11 and r=7 [2]
k+= (--m%5)*(m++ *(10 + r++))
𝑥𝑦
iii) Write the Java expression for 𝑥 3 + 𝑦3 − [2]
𝑧
iv) Give the output of the following program segment (show the rough work): [2]
int n=4279;
int d,s;
s=0;
while(n>0)
{
d=n%10;
s=s+d;
n=n/100;
}
System.out.println(“The sum is=”+s);
String s= “COMMITTEE”;
Page 2 of 4
System.out.println(s.substring(3,(s.lastIndexOf(‘T’))));
Question 3. [15]
Write a program to define a class HotelBill as follows:
Data members:
cust_name, check_in_date, check_out_date, no_of_days, bill.
Member methods:
HotelBill( ): default constructor to initialize all the member variables.
void display( ): to display customer name, no of days, and bill amount. Write a main method to
create an object of the class and call the member methods.
Question 4. [15]
Design a class to overload a function Sum( ) as follows:
int Sum(int A, int B) – with two integer arguments (A and B) calculate and return the sum of all the
even numbers in the range of A and B.
double Sum(double N ) – with one double arguments(N) calculate and return the product of the
following series:
sum = 1.0 x 1.2 x 1.4 x …………. x N
int Sum(int N) – with one integer argument (N) calculate and return the sum of only odd digits of the
number N.
Question 5. [15]
Using the switch statement, write a menu driven program to perform the following operations:
To Print the value of Z where Z = (𝑥³ + 0.5𝑥) / 𝑌 where x ranges from – 10 to 10 with an increment of
2 and Y remains constant at 5.5.
Question 6. [15]
Write a program in Java to check whether a given number is a duck number or not.
Page 3 of 4
[Note: A number is said to be a duck number if it contains zero, but the number 0 should not be in
the initial position of the number.
For example: 4509, 3024, 6780, etc. are examples of duck numbers.
Whereas the numbers such as 0123, and 09780 are not duck numbers.
Page 4 of 4