Exam Paper Print – Computer Sir Ki Class


Lost your password?

Don't have an account ?
Register (It's FREE) ×

Exam Paper: Exam Paper Print (JAVA) No. of Q.26
Q.01A 2

What is Inheritance ?

Q.01B 2

Name the operators listed below
(i) <     ( ii) ++      (iii) &&     (iv) ?:

Q.01C 2

State the number of bytes occupied by char and int data types.

Q.01D 2

Write one difference between / and % operator.

Q.01E 2

Give the output of the following statements:
i) System.out.println(x[1]);
ii) System.out.println(x[3].length());

Q.02A 2

Name the following:
(i) A keyword used to call a package in the program.
(ii) Any one reference data type.

Q.02B 2

What are the two ways of invoking functions?

Q.02C 2

State the data type and value of res after the following is executed:
char ch=’t’;
res= Character.toUpperCase(ch);

Q.02D 2

Give the output of the following program segment and also mention the number of times the loop is executed:

int a,b;
for (a = 6, b = 4; a <= 24; a = a + 6)
  if (a%b ==0)

Q.02E 2

Write the output:
char ch = ‘F’;
int m = ch;
System.out.println(m + ” ” + ch);

Q.03A 2

Write a Java expression for the following:
ax5 + bx3 + c


Q.03B 2

What is the value of x1 if x=5?
x1= ++x – x++ + –x

Q.03C 2

Why is an object called an instance of a class ?

Q.03D 2

Convert following do-while loop into for loop.

int i=1;
int d=5;

Q.03E 2

Differentiate between constructor and function.

Q.03F 2

Write the output for the following:
String s=”Today is Test” ;
System.out.println(s.substring(0,7) + ” ” +”Holiday”);

Q.03G 2

What are the values stored in variables r1 and r2:
(i) double r1 = Math.abs(Math.min(-2.83, -5.83));
(ii) double r2 = Math.sqrt(Math.floor(16.3));

Q.03H 2

Give the 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);

Q.03I 2

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(“” ); }
System.out.println(“WIN” ); }

(i) How many times does the inner loop execute?
(ii) Write the output of the program segment.

Q.03J 2

What is the difference between the Scanner class functions next() and nextLine()?

Q.04A 15

Define a class ElectricBill with the following specifications:

class : ElectricBill
Instance variables / data member:
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 Rs.2.00
Next 200 units Rs.3.00
Above 300 units Rs.5.00
A surcharge of 2.5% charged if the number of units consumed is above 300 units.
void print ( ) – To print the details as follows:
Name of the customer: ………………………
Number of units consumed: ………………………
Bill amount: ………………………
Write a main method to create an object of the class and call the above member methods.

Q.05A 15

Write a program to accept a number and check and display whether it is a spy number or not. (A number is spy if the sum of its digits equals the product of its digits.)
Example: consider the number 1124, Sum of the digits = 1 + 1 + 2 + 4 = 8
Product of the digits = 1 x 1 x 2 x 4 = 8

Q.06A 15

Using switch statement, write a menu driven program for the following:

(i) To find and display the sum of the series given below:
S = x1 – x2 + x3 – x4 + x5 … – x20, where x = 2.
(where x = 2)

(ii) To display the following series:
1 11 111 1111 11111
For an incorrect option, an appropriate error message should be displayed.

Q.07A 15

Write a program to input integer elements into an array of size 20 and perform the following operations:
(i) Display largest number from the array.
(ii) Display smallest number from the array.
(iii) Display sum of all the elements of the array.

Q.08A 15

Design a class to overload a function check( ) as follows:
(i) void check (String str , char ch ) – to find and print the frequency of a character in a string.
Example :
Input: Output:
str = “success” number of s present is =3
ch = ‘s’
(ii) void check(String s1) – to display only vowels from string s1, after converting it to lower case.
Example :
s1 =”computer” Output : o u e

Q.09A 15

Write a program to input forty words in an array. Arrange these words in descending order of alphabets, using selection sort technique. Print the sorted array.