SXCS Computer Applications 2024 Rehearsals
SXCS Computer Applications 2024 Rehearsals
i) Parameters which receive the values from the calling method are termed as parameters.
(a) actual (b) formal (c) reference (d)class
v) When String m is compared to n, the resuit obtained is greater than zero. Which of the following is true?
(a) m comes before n in the dictionary. (b) n comes before m in the dictionary.
(c) m and n are equal. (d)m and n have the same length.
vi) Arrange the following in the descending order of number of bytes occupied.
I. char x[20]
II. int af4](2]
III. double b[6}
(a) II, II, I (b) II, I, I (c) II, III, I (d) I, I, III
viiWhich of the following statements are valid for static membe methods of a class?
as
I. They can access static as well non-static data members
N, They can call non-static megber methods.
II\An object is required to invoNe the methods.
(a) Iand I (b) II and III (c) I and I (a) Only
Nane the vevidle
I het u
4 olass
ix)What is the outcome of the following code snippet:
public class Test
xiv) Which access specifier allows accessibility by all classes in the same package, but only by subclasses in a
different package?
(a) public (b) private (c) protected (d) default
xvii) Which of the following is a valid statement to print the following sentence:
Raj said “Good morning"
(a) System. out. printin("Raj said “Good morning");
(b) System. out. println("Raj said \Good morningl);
(c) System. out. printin("Raj said \"Good morning|" ");
(d) System. out. printin("Raj said Good morning");
Question 2
i)) Convert the following while loop to the corresponding for loop: {2]
System.out.println(m*n);
n--;
[2]
i) What will be the output of the following code?
int m=2; int n=15;
for(int i= 1; i<5; it+);
mt+; --n;
System.out.println("m=" +m):
System.out.printIn(“n= n);
ii) Consider the following code and answer the questions that follow:
(2]
class academic
int x,y;
void access()
int a,b;
academic student-new acadenic();
System.out.printin(Object Created");
}}
a. Name the instance variables used in the class.
b. Write the name of local variables used in the program.
int i;
int a[6]-{0,1,8,7,6,4};
for(i-0;i<=a.length0;it+)
System.out.printin(a[i);
}}
vi)Predict the output (show working):
int i-5;
do
System.out.printIn(+-+it5);
}while(+-+i<ll);
System.out.println(i);
p*=i;
}while
(tti<s);
System.out.println(p);
vii) Using Java library functions, write statements with appropriate datatypes for the following: [2)
i) To extract “SP" from "MISSISSIPP!".
ii) Toremove all leading and trailing spaces froma string str.
ix) Replace the following set of if-else statements with switch-case statements: {2]
void work(char code)
if(code-=A')
System.out.println(“Well Done");
else if(code-=
B
|| code== 'C)
System.out.println(“Satisfactory");
else if(code= D'
jlcode-= *E')
System.out.println(More effort required"):
Question 4 [15]
Write a program to input 10 numbers into an integer array and store only the numbers occurring once into another
array and display it.
For example, if the given array contains 99, 12, 34, 7, 99, 36, 12, l6, 14, 123
The resultant array should be: 34, 7, 36, 16, 14, 123
Question5 [15]
Design a program to check the strength of a password. A strong password should satisfy the following conditions:
-length of the password should be at least 12 characters
shoulda at least have 4 upper case letters, 4 lower case letters, 2 digits, 2 special characters
Define class to accept the password and check and print whether the password is strong or not.
Question 6 [1S]
Define a class to overload the method that performs as follows
:
Question 7
Define a class to accept values into a 3x3 array and check and print if it is a special array or not. An array
is a special array if the sum of the even elements = sum of the odd elements.
Example: AJ0-{{4,5, 6}, { 5,3, 2}, {4, 2, 5}};
Sum of even elements = 4+6+2-+4+2 =18
Sun of odd elements= 5+5+3+5=18
Question 8 [15)
Input an integer and form a new number by removing allodd digits fron it. Print the new number.
For example,
Input: 123456
Output: 246