Questions – Exam Papers – Computer Sir Ki Class


Lost your password?

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

Exam Paper: Questions - Exam Papers (JAVA) siteicon No. of Q.26

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

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

Write one difference between / and % operator.

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

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

What are the two ways of invoking functions?

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

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)

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

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


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

Why is an object called an instance of a class ?

Convert following do-while loop into for loop.

int i=1;
int d=5;

Differentiate between constructor and function.

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

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

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

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.

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

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.

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

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.

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.

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

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.

Total Marks.130