Questions – Exam Papers – Computer Sir Ki Class

Login


Lost your password?

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


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

What are the default values of the primitive datatypes int and float?




Name any two OOP’s principles.





Identify the literals listed below:
(i) 0.5 (ii)’A’ (iii) false (iv) “a”




Name the wrapper class of char type and boolean type.




Evaluate the value of n if the value of p=5, q=19
int n = (q-p) > (p-q) ? (q-p) : (p-q);




Arrange the following primitive data types in an ascending order of their size:
(i) char (ii) byte (iii) double (iv) int




What is the value stored in variable res given below:
double res = Math.pow(“345”.indexOf(‘5’), 3);




Name the two types of constructors.




What are the values of a and b after the following function is executed, if the values passed are 30 and 50.

void paws(int a, int b) {
a = a + b;
b = a - b;
a = a - b;
System.out.println(a + " , " + b);
}



State the data type and the value of y after the following is executed :

char x = '7';
y = Character.isLetter(x);



What is the function of catch block in exception handling? Where does it appear in a program?




State the output of the following  program segment is executed :

String a = "Smartphone", b = "Graphic Art";
String h = a.substring(2, 5);
String k = b.substring(8).toUpperCase();
System.out.println(h);
System.out.println(k.equalsIgnoreCase(h));



The access specifier that gives most accessibility is __________ and the least accessibility is ___________ .




(i) Name the mathematical function which is used to find sine of an angle given in radians
(ii) Name a string function which removes the blank spaces provided in the prefix and suffix of a string




(i) What will the code print?

int arr[] = new int [5];
System.out.println(arr);

(i) 0 (ii) value stored in arr[0] (iii) 0000 (iv) garbage value

(ii) Name the keyword which is used to resolve the conflict between method parameter and instance variables/fields




State the package that contains the class :
(i) BufferedReader
(ii) Scanner




Write the output of the following code segment:

char ch;
int x = 97;
do {
  ch = (char) x;
  System.out.print(ch + " ");
  if (x % 10 == 0)
    break;
  ++x;
} while (x <= 100);

 




Write the Java expression for: a2+b2/2ab




If int y = 10 then find int z = (++y * (y++ + 5));




Define a class ParkingLot with the following description:
Instance variables/data members:
int vno – To store the vehicle number
int hours – To store the number of hours the vehicle is parked in the parking lot
double bill – To store the bill amount
Member methods:
void input() – To input and store vno and hours
void calculate() – To compute the parking charge at the rate of Rs.3 for the first hour or part thereof, and Rs.1.50 for each additional hour or
part thereof.
void display() – To display the detail
Write a main method to create an object of the class and call the above methods




Write two separate programs to generate the following patterns using iteration(loop) statements:
(a)

1 *
2 * #
3 * # *
4 * # * #
5 * # * # *

(b)
[/code]
5 4 3 2 1
5 4 3 2
5 4 3
5 4
5
[/code]




Write a program in to input and store all roll numbers, names and marks in 3 subjects of n number of students in five single dimensional
arrays and display the remark based on average marks as given below:
Average marks = total marks/3

AVERAGE MARKS REMARK
85 – 100 EXCELLENT
75 – 84 DISTINCTION
60 – 74 FIRST CLASS
40 – 59 PASS
Less than 40 POOR



Design a class to overload a function Joystring() as follows: [15]
(i) void Joystring(String s, char ch1, char ch2) with one string and two character arguments that replaces the character argument ch1 with
the character argument ch2 in the given string s and prints the new string
Example:
Input value of s = “TECHNALAGY”
ch1 = ‘A’
ch2 = ‘O’
Output : “TECHNOLOGY”
(ii) void Joystring(String s) with one string argument that prints the position of the first space and the last space of the given String s.
Example:
Input value of = “Cloud computing means Internet based computing”
First Index : 5
Last Index : 36
(iii) void Joystring(String s1, String s2) with two string arguments that combines the two strings with a space between them and prints the
resultant string
Example :
Input value of s1 = “COMMON WEALTH”
s2 = “GAMES”
Output : “COMMON WEALTH GAMES”
(use library functions)




Write a program to input twenty names in an array. Arrange these names in descending order of alphabets , using the bubble sort
technique.




Use switch statement,write a menu driven program to:
(i) To find and display all the factors of a number input by the user (including 1 and excluding number itself.)
Example :
Sample Input : n = 15.
Sample Output : 1, 3, 5
(ii) To find and display the factorial of a number input by the user. The factorial of a non-negative integer n ,denoted by n!,is the product of
all integers less than or equal to n.
Example :
Sample Input : n = 5
Sample Output : 120.
For an incorrect choice, an appropriate error message should be displayed.



Total Marks.130