0% found this document useful (0 votes)
47 views

Class10 QuestionBank HalfYearly

Uploaded by

Bhavya Singhania
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)
47 views

Class10 QuestionBank HalfYearly

Uploaded by

Bhavya Singhania
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
You are on page 1/ 19

Question Bank

Subject :- Computer Applications


Class :- X
Part – I
Based On Half yearly syllabus.

Chapter-Introduction to OOP

1. Choose the correct options:


a)
Vehicle

car Bicycle Truck

Name the feature of java depicted in the above picture.


i. Encapsulation
ii. Inheritance
iii. Abstraction
iv. Dynamic Binding

b) A java program developed and executed by the users without using web
browser
is known as:
i. object
ii. application
iii. applet
iv. byte code

c) How is encapsulation implemented in a program?


i. Using a class
ii. Using only functions
iii. Using only variables
iv. Using only keywords

d) The process of combining data and functions that enables them to be


together as single entity is called:
i. Inheritance
ii. Encapsulation
iii. Classification
iv. Attributes

Page 1 of 19
2. Answer the following questions.
a) Name four basic principles of OOP.
b) How Data Encapsulation and Data Abstraction are interrelated in OOP?
c) State any four features of Java.
d) State any two advantages of OOP.

Elementary Concept of Objects and Classes

1. Choose the correct answer.


a) ____________ is a template to crate similar objects that share common
characteristics and behaviour.
i) A function
ii) A procedure
iii) An attribute
iv) A class
b) The values of an object’s _____________ represent the state of the object.
i) Methods
ii) Procedures
iii) Attributes
iv) Classes
c) ___________ number of objects can be created of a class
i) 1
ii) 2
iii) 5
iv) Many
d) While creating an object, ____________ operator is used for dynamic allocation of
the object.
i) Assignment
ii) new
iii) dot(.)
iv) delete

2. Answer the following questions.


a) Write a Java statement to create an object “square” of class “Shape”.
b) A class is also referred to as ‘Object Factor’- Explain
c) Give the reason why a class is known as: A user-defined data type.
d) Differentiate between class and object.

Values and Data Types

1. Choose the correct answer.


a) Which of the following is not a valid keyword in JAVA?
i) while
ii) break

Page 2 of 19
iii) main
iv) class
b) Size of double data type is
i) 4 bytes
ii) 1 byte
iii) 2 bytes
iv) 8 bytes

c) Implicit type conversion is also known as


i) type casting
ii) converter
iii) changer
iv) coercion
d) ____ escape sequence gives a horizontal tab.
i) \h
ii) \t
iii) \n
v) \b

2. Answer the following questions.


a) Write the resultant data type by showing steps using flow lines for the
following expression:
float f, int i, char c, double d
c*f/i–d
b) Rohit wrote the following code snippet in Java but on execution, it shows
error. Explain the reason.
int A = 3.141;
System.out.print(A);
c) Give the output:
char ch = 'C' + 5;
System.out.print(ch);
d) What will be the output of the following line?
System.out.println("He said \t \"It\'s raining\" ");

Page 3 of 19
Operators in Java

1. Choose the correct answer.


a) Which among the following is used to represent single-line comment?
i) //
ii) \\
iii) /*
iv) */
b) Ternary operator is also known as:
i) Prefix Operator
ii) Shorthand Operator
iii) Conditional Operator
iv) Logical Operator
c) Syntax of ternary operator is-
i) Variable=<condition>?<value if true>:<value if false>
ii) <condition>?variable=< value if true >:variable=< value if true >
iii) Variable=<condition>?< value if true >:< value if true >
iv) Variable=<condition>:< value if true >?< value if true >

d) ___________ operator is used to allocate computer memory dynamically.


i) dot(.) operator
ii) new operator
iii) ?: operator
iv) = operator

2. Answer the following questions.


a) State the difference between = and = =.
b) Write equivalent Java expressions for the following:
3
𝑇 = √𝑥 2 + 𝑦 2 + 𝑧 4
c) Find out the value of x.
int x=5, y=3;
x*=++y % x++ + ++x / --y;
d) Rewrite the following statement using ternary operator.
public cal (int x, int y)
{
int a;
if (x>y)
{
if (x>10)
a=x+10;
else
a=x*10;
}
else

Page 4 of 19
a=x*y;
}

3. Write a menu driven program in java to accept a choice and perform the
following operations as given below.
Choice 1: Input the three sides of a triangle and check whether it forms a
triangle or not. If it forms a triangle, check whether it is an equilateral,
isosceles or a scalene triangle.
(Hint: To form a triangle, each side should be less the sum of the other two `
sides.
To form an equilateral triangle every side should be equal.
To form an isosceles triangle any two sides should be equal.
To form a scalene triangle all three sides should be different from each other.)

Choice 2: Accept three angles of a triangle as parameter and check whether


it can form a triangle or not. If it forms a triangle, check whether it is an acute
angled triangle, obtuse angled triangle or right-angled triangle.
(Hint: To form a triangle, the sum of the angles should be 180 degrees.
To form an acute angled triangle, the interior angles should be less than 900.
To form an obtuse angled triangle one of the interior angles should be more
than 900. To form a right angled triangle one of the interior angles should be
900.)

Inputs in Java

1. Choose the correct answer.


a) To apply Scanner class the following package is necessary to be
imported:-
i) java.math
ii) java.lang
iii) java.util
iv) java.awt

b) The default delimiter is


i) Comma(,)
ii) Dot(.)
iii) semicolon(;)
iv) white space
c) Which of the following is not a valid method to enter data in java:-
i) Using Function Argument
ii) Using Wrapper Class
i) Using Scanner Class
ii) Using Command Line Argument
d) Which is not a valid comment statement in java?
i) //
ii) /* */
ii) /** **/
iii) /** */

Page 5 of 19
e) Identify the type of error in following statement to calculate the average of
three numbers (a, b & c) :-
double average = a + b +c/3;
i) Syntax Error
ii) Logical Error
iii) Runtime Error
iv) No Error

2. Answer the following Questions:-


a) Name the keyword used to include a package in your program.
b) Name the error when a number is divided by zero.
c) Name the default package in java.
d) Name the function to accept an integer value and a fractional value from the
user using Scanner class.
e) What are the differences between next() and nextLine() function?

Mathematical Library Methods

1. Choose the correct answer.


a) What type of value is returned by Math.sqrt( )?

i) int
ii) float
iii)double
iv) All

b) Which of the following syntax is true to find the square root of a number?

i) sqrt(a)
ii) Math.sqrt(a)
iii) Squareroot(a)
iv) None

c) Name the class that is used for different Mathematical functions.

i) Math
ii) Scanner
iii) Maths
iv) Calc

d) Give the output of the Math.abs(x); when x = -9.99

i) -9.99
ii) 9.99
iii) 0.99
iv) None

Page 6 of 19
e) Give the output of Math.sqrt(x); when x = 9.0

i) 3
ii) 3.0
iii) 3.00
iv) all

2. Predict the output:


a) System.out.println(Math.sqrt(10.24));
b) System.out.println(Math.round(-99.4));
c) System.out.println(Math.cbrt(Math.min(72,27));
d) System.out.println(Math.floor(Math.max(-25.5, -12.5)));
e) System.out.println(Math.abs(Math.ceil(-0.95)));

3. Write a program in Java to input three numbers and display the greatest and
the smallest of the two numbers using Mathematical Library functions only.

4. Write a program in Java to calculate and display the hypotenuse of a Right-


Angled Triangle by taking perpendicular and base as inputs.
Hint: h = √p2 + b2

Conditional Statements
1. Choose the correct answer.
a)Which of the following is multi-branching statement in JAVA?
a. if
b. else
c. switch
d. for

2. A compound statement is enclosed within


a. ( )
b. [ ]
c. < >
d. { }

3. In switch-case which data type is not allowed?


a. char
b. double
c. int
d. String
Page 7 of 19
4. Fall through happens in switch-case due to absence of ____.
a. case
b. default
c. break
d. condition

1. Find out the output of the following code:


if (7>=10);
System.out.println(“YES”);
System.out.println(“NO”);

2. Give the output of the following if the choice = 1


switch (choice)
{
case 1:
System.out.print(“Python”);
case 2:
System.out.print(“JAVA”);
break;
default:
System.out.print(“Invalid Input”);
}

3. Rewrite the following statement using if else:


String s = a>b ? “Good” : “Bad”;

4. Identify the error and rewrite the correct code:


if a*a > b
System.out.print(“Invalid Input”);
Else
System.out.print(“Invalid Input”);

Page 8 of 19
Programs

Q1. Central Library charges late fine for book submission as per the following:

No. of Days Fine


First 15 days ₹ 1 per day
Next 30 days ₹ 2 per day
More than 45 days ₹ 4 per day

Write a Java program to accept the total number of late days. Calculate and
display the total late fine to be paid by the borrower.

Q2. The table below shows the rate of income tax for an Employee:

Taxable Income (in Rs) Income Tax (in Rs)


Up to Rs.2,00,000 7% on the income exceeding
Rs.2,00,000
More than Rs.2,50,000 and less than or 10% on the income exceeding
equal to Rs.5,00,000
Rs.2,50,000
More than Rs.5,00,000 14% on the income exceeding
Rs.5,00,000 plus an additional
Rs.15,000

Write a program in Java to accept the name and taxable income of a person.
Calculate and display the income tax payable along with the name of the person.

Q3. Write a program to input three angles of a triangle and check whether
a triangle is possible or not. If possible then check whether it is an acute-angled
triangle, right-angled or an obtuse-angled triangle otherwise, display 'Triangle not
possible'.
Sample Input: Enter three angles: 40, 50, 90
Sample Output: Right Angled Triangle

Page 9 of 19
Q4. Write a menu driven JAVA program using switch case only to perform the
following:
If user chooses 1 then accept a number and check whether it’s a prime number or
not. (A number is prime if it is divisible only by 1 and itself)
If user chooses 2 then accept a number and find the sum of its digits.
Eg: If number is 123 then output should be 1+2+3 = 6
For any other choice display “Incorrect Input”.

Iteration through Loops


1. Choose the correct answer.
a. ____________ is not a jump statement.

i) break
ii) void
iii) continue
iv) return

b. Endless loop is also known as _________.

i) Infinite loop
ii) Delay loop
iii) Bodyless loop
iv) Null loop

c. To execute a loop for 10 times, which of the following statement will be used.

i) for(int i=6;i<=26;i=i+2);
ii) for(int i=3;i<=30;i=i+3);
iii) for(int i=0;i<10;i=i+1);
iv) All of the above

d. Which of the following is an exit controlled loop?

i) for
ii) while
iii) do while
iv) do

2. Answer the following questions:


a) Convert the following segment into an equivalent do loop.
int x,c;
for (x=10, c=20; c>=10;
c = c – 2) x++;

Page 10 of 19
b) Analyze the following program segment and determine how many times
the loop will be executed and what will be the output of the program
segment.
int k=1, i=2;
while (++i<6)
k*=i;
System.out.println(k);
c) State the difference between entry controlled loop and exit controlled
loop.
d) Analyze the given program segment and answer the following questions:
for(int i=3;i<=4;i++)
{
for(int j=2;j<i;j++)
{
System.out.print(“Hello ”);
}
System.out.printlin(“WIN”);
}
i. How many times does the inner loop execute ?
ii. Write the output of the program segment.

3. Write a program to print the first 15 numbers of the Pell series. Pell
series is such a series which starts from 1 and 2 , and subsequent
numbers is the sum of twice the previous number and the number
previous to the previous number. Pell series: 1, 2, 5, 12, 29, 70, 169,
408, 985, 2378, 5741, 13860, …
4. Write a program to input two integers and check whether it forms an
amicable pair or not. An amicable pair is such that, the sum of the
factors excluding itself of one number is the other number and sum
of the factors excluding itself of the other number is this number.
Example, (220, 284). Since sum of factors
excluding itself of : 220=
1+2+4+5+10+11+20+22+ 44+55+110=284
284= 1+ 2+4+71+142=220.

5. Write programs to display the following patterns.


a) b)
54321
1
01 43215
101 32154
0101
10101 21543
010101 15432

Page 11 of 19
Class as the Basis of all Computation
1. Choose the correct answer.
a) The access specifier which prohibits a class member from being used outside a
class is ____________
i) Private
ii) Public
iii) Protected
iv) Default
b) A static method is also called a ____________
i) Instance method
ii) Class method
iii) Defined method
iv) Fixed method
c) Code reuse is implemented by __________
i) Abstraction
ii) Inheritance
iii) Polymorphism
iv) Function overloading
d) ___________ keyword is used to provide access to classes stored inside a package in
our program.
i) import
ii) this
iii) private
iv) final

2. Answer the following questions.


a) Name the Java keyword that:-
i) Indicated that a method has no return type.
ii) Stores the address of the currently calling object.

b) Write differences between User-defined data type and Primitive data type.
c) Differentiate between public and private modifiers for the members of a class.

3. Define a class ElectricBill with the following specifications:


Class : ElectricBill
Instance variables/data memebts:
String n: to store the name of the customer
int units: to store the number of units consumed
double bill: to store the amount to be paid
Member methods:
void accept() : to accept the name of the customer and number of units
consumed.
void calculate() : to calculate the bill as per the following tariff:
Number of units Rate per unit
First 100 units 2.00/unit
Next 200 units 3.00/unit
Above 300 units 5.00/unit

A surcharge of 2.5% charged if the number of units consumed is above 300 units.
void print(): to print the details as follows:

Page 12 of 19
Name of the customer: …………………….
Number of units consumed : ……………………
Bill amount : ……………………………

Write a main method to crate an object of the class and call the above member
methods.

Chapter-Library Classes:
Question 1
Choose the correct options:
a) Which of the following is not an OOP concept?
i. encapsulation
ii. polymorphism
iii. exception
iv. abstraction

b) What are the return type and type of argument of the isWhiteSpace( )
method?
i. char, char
ii. char, boolean
iii. boolean, char
iv. Boolean, (no argument)

c) _______ means automatically converting the primitive data type into


corresponding objects.
i. Autoboxing
ii. Unboxing
iii. Widening
iv. Typecasting

d) What is the result of the expression:


Integer.valueOf(“20”)+Integer.valueOf(“10”)?
i. Runtime error
ii. 2010
iii. 30
iv. 1020

Question 2
a) State the output of the following program snippet:
int n=97;
char ch= Character.toUpperCase((char)n);
System.out.println(ch + “Great Victory”);

Page 13 of 19
b) Give output of the following code:

String A="26", B="100";


String D=A+B+200;
int x=Integer.parseInt(A);
int y=Integer.parseInt(B);
int d=x+y;
System.out.println("Result 1= "+D);
System.out.println("Result 2= "+d);

c) Predict the output of the following code snippet:


char ch=’x’; int n=5;
n=n+(int)ch;
char c=(char)n;
System.out.println((char)((int)c-26));

d) Predict the output of the following code snippet:


char ch=’B’;
char chr=Character.toLowerCase(ch);
int n=(int)chr-10;
System.out.println((char)n+”\t”+chr);

Question 3
Write a program to input two characters. Find the difference (d) between
their ASCII
codes. Display the following messages along with difference:
If d=0 : Both the characters are same.
If d<0 : First character is smaller.
If d>0 : Second character is smaller.
Sample Input :D
P
Sample Output : d=68-80= - 12
First character is smaller.
Question 4
Write a program to input a character, check whether it is an alphabet or not,
if the character is an alphabet, then change to its opposite case, otherwise
print “Not an alphabet.”
Sample Input 1 : A Sample Input 2 : 5
Sample Output 1 : a Sample Output 2 : “Not an
alphabet”

Question 5
Write a program to input a letter. Find its ASCII code. Reverse the ASCII code and
display the equivalent character.

Page 14 of 19
Sample Input :Y
Sample Output : ASCII code = 89
Reverse the code = 98
Equivalent character: b

Function/Methods

1. Choose the correct answer.

a) What is the return type of a method that does not return any value?
i) int
ii) float
ii) void
iv) double

b) What is the process of defining more than one method in a class differentiated
by method signature?
i) Function overriding
ii) Function overloading
iii) Function doubling
iv) None of the mentioned

c) Which method can be defined only once in a program?


i) main method
ii) finalize method
iii) static method
iv) private method

d) A type of parameter that are used to identify what data is to be passed to a


function is called:
i) Formal parameter
ii) Actual parameter
iii) Both a and b
iv) None of these
e) The number of values that a function can return is:
i) 1
ii) 2
iii) 3
iv) 4

2. Write function prototypes for the following:


a) Private access method sum which accepts three int type variables as
parameters and return a float type.
b) Default access method “length” which accepts a String type variable as
parameter and returns an int type.

Page 15 of 19
c) Public access method “increment” which accepts an object of Myclass
type as parameter and does not return any value.
d) Protected access method largest which accepts a float type, int type and
double type data as parameters and have a byte type as return type.
e) Public access static method calculate which accepts a byte and int type
data type as parameters and return float type.

3. Answer the following questions:

a) Write two advantages of using functions in a program.


b) Explain the function of the ‘return’ statement.
c) If a function contains several return statements, how many of them will
be executed?
d) Name the keyword that causes the control to transfer back to the method
call.
e) What is the role of the keyword ‘void’ in declaring functions?
f) Classify functions depending upon the value it returns.
g) Differentiate between Formal Parameter and Actual Parameter.
h) State the difference between function prototype and function signature.
i) How are functions called? How does it return a value?
j) State the difference between Call by Value and Call by Reference.

k) How are the following passed?


(i) Primitive types (ii) Reference types
l) Differentiate between pure and impure function.

4. Write Java programs for the following:


a) Create a function which accepts an integer as parameter and return
the sum of its digits. Create another function to input 10 integers and
find the sum of the digits of each number.

b) Create a function which accepts an integer as parameter and return the


largest digit. Create another function to input 10 integers and find the
sum of the largest digit of each number.

c) Create a method which accepts temperature in Celsius and return its


Fahrenheit equivalent. Create another method which accepts
temperature in Fahrenheit and return its Celsius equivalent. Also
create a method to invoke the above methods.

Page 16 of 19
d) Create a class with the following methods:
a. int sum(int n), which finds the sum of the digits in n and returns it.
b. void call() to input an integer using scanner and find the sum of its
digits using the above
method.
e) Create a class with the following methods:
a. int sum(int n), which finds the sum of the digits in n and returns it.
b. void call() to input 10 integers using scanner and find the sum of its
digits of each integer value entered by the user using the above
method.

f) Create a class with the following methods:


a. boolean prime(int n), which returns true if n is prime otherwise
returns false.
b. void call() to input 10 integers using scanner and find the sum of those
integers which are
prime numbers using the above method.
g) Create a class with the following methods:
a. boolean is Armstrong(int n), which returns true if n is Armstrong
number otherwise
returns false.
Armstrong numbers are those numbers, whose sum of the cube of
its digits is equal to
the number.
Eg. 153 = 13 + 53 + 33
b. void call() to input 10 integers using scanner and find largest
Armstrong number if any.

h) Create a class with the following methods:


a. boolean prime(int n), which returns true if n is prime otherwise
returns false.
b. void call() to input 2 integers using scanner and print only the
prime numbers between the given integers.

Arrays

1. Choose the correct answer.


a) In int a[]={11,22,33,44,55,66,77} what is a.length?
i) 5
ii) 6
iii) Error
iv) 0
Page 17 of 19
b) How much memory will be occupied by double X[5]?
i) 10 bytes
ii) 20 bytes
iii) 6 bytes
iv) 40 bytes

c) What will be the first index and the last index for an array int X[10]:
i) 1 , 10
ii) 1, 11
iii) 0, 9
iv) 0,10

d) Identify the non – border elements of a 2D array


int A[][] ={{1,2,3,4},{5,6,7,8},{9,10,11,12},{13,14,15,16}}
i) 9,10,11,12
ii) 6,7,10,11
iii) 5,6,7,8
iv) 4,8,12,16

e) Assertion(A): Array cell numbers or index numbers are also known as


subscripts.
Reason(R): As array contains many subscripts in it , the array itself is called
a subscripted variable.
i) Both Assertion (A) and Reason (R) are true and Reason (R) is a correct
explanation of Assertion (A
ii) Both Assertion (A) and Reason (R) are true and Reason (R) is not a
correct explanation of Assertion(A)
iii) Assertion (A) is true and Reason (R) is false
iv) Assertion (A) is false and Reason (R) is true

2. Answer the following questions.

a. If a[ ] = { 1,5,8,3,10};
iii) What is the value of a.length?
iv) What is the value of a[4] * a[4-4]?

b. If int z[] = {76,23,4,8,50}; what will be the output?


i) System.out.println(z[4] – 4 + z[5 - 5]);
ii) System.out.println(z[1] % (z[3] * z[2]));

c. What value will be stored in the array after execution of the following code ;-

int a[] = {19,-67,25,91,43};


for(i=0;i<5;i++)
a[5-i-1] = a[i];

d. If a[]={11,22,33,44,55} then what vales are stored in the array after execution
of the following code :-
for(int i =a.length-1;i>0;i--)
a[--i]= a[i]+10;
Page 18 of 19
e. int arr[ ][ ]={{12,-7,54},{11,23,-9},{18,5,5}};
i) How much memory will be occupied by the matrix arr[ ][ ] ?
ii) What will be the output of the following statement?
System.out.print(arr[0][0]+arr[2][0]+arr[0][2]+arr[2][2])

3. WAP to store values in an array. Display the original array. Arrange the
elements in descending order of their values using Selection Sort technique.

4. WAP to store values in a matrix. Display the original matrix. Also display sum
of all the elements of the given matrix.

5. WAP to store values in a character array. Find the lower case alphabets
present in the array along with their ASCII values in a tabular format. Also
display numbers of all the lower case alphabets.

6. WAP to store values in a single dimensional integer array. Display the highest
and the second highest elements from the given array.

7. Write a program to store names of ten cricketers and name of the countries
they play for in two different string arrays. accept the name of a cricketer and
search his/her name in the array using Binary Search technique. If found
display the corresponding country name otherwise display suitable message.

8. WAP to store values in a square matrix of size NxN. Display the original matrix.
Replace all the diagonal elements (both right and left) with zero. Display the
modified matrix.

9. WAP to store values in a double array. Find the average/mean value of all the
elements. Display the mean value also display the difference of each element
from the mean value.

10. WAP to store vales in a 2D array. Display the original array. Find the
sum of the elements in each column.

******************

Page 19 of 19

You might also like