SXCS RE Computer 2024
SXCS RE Computer 2024
vii) Which of the following statements are valid for static member methods of a class? Cam
I. They can access static as well as non-static data members.
II. They can call non-static member methods.
IL. An object is required to invoke the methods. b)
(a) Iand II (b) Il and III (c) I and [II (d) Only II
ix) What is the outcone of the following code snippet:
public class Test
System.out.println(m*n);
n--;
int x,y;
void access()
int a,b:
academic student-new academic();
System.out.printin(Object Created");
iv) Write the prototype ofa function which takes in 2 integers and 1
String arguments and returns a value {2)
which is either true or false.
p*=i;
} while (+ti<s);
System.out.println(p);
viii) Using Java library functions, write statements with appropriate datatypes for the
i) Toextract "SIP" from following: [2]
MISSISSIPPI".
ii) To remove all leading and trailing spaces from a
string str.
ix) Replace the following set of if-else
statements with switch-case statements: [2]
void work(char code)
if(code=='A')
else System.out.printin(Well Done")};
if(code== B' | code= 'C)
System.out.println(Satisfactory");
else if(code= D'|code=E)
System.out.println("More effort required");
x) If m and n are int type variables, what will
be the result of the expression m%n
when m= -14 and n= -3? (2]
SECTION B
(Answer any four questions from this Section.)
Each program should be written using variable description /mnemonic codes so that the logic of the
program is clearly depicted.
Question 3
Define a class called Mobike with the following description:
Instance variabless/ Data members:
bno:to store the bike's number
phno : tostore the phone number of the customer
name tostore the name of the customer
days : to store the number of days the bike is taken on rent
charge : to calculate and store the rental charge
Member methods:
void input () :to input and store the details of the customer
void compute (): to compute the rental charge. The rent for aMobike is charged on the following basis
First five days : Rs.500per day
Next five days : Rs.400 per day
Rest of the days: Rs.200per day
void display () : to display the details in the following format:
Bike No. Phone No. Name No. of days Charge
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, 16, 14, 123
The resultant array should be: 34, 7, 36, 16, 14, 123
Question 5
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
’should at least have 4 upper case letters, 4 lower case letters, 2 digits,2 special characters
Define a class to accept the password and check and print whether the password is strong or not.
Question 6 [15]
Define a class to overioad the method that performs as follows :
void perforn( int x]) - to display the largest element of the array.
Exampie: (4, 5, 16, 6, 12, 9)
Largest: !6
void perform (String s,char ch)
If ch is F print the first 5 characters, if ch is 'L' print the last Scharacters
Example: s= CARPENTER"
ch = F
Output: CARPE
ch = L
Output: ENTER
void perform(int n) : to print the Product of the first and last digits of the number
Example: ifn = 45326
Output: 4x6-24
Question 7 [15]
Define a class to accept values into a 3×3 array and check and print if it is a special array or not. An array
is a special array if the sumof the even elements =sum of the odd elements.
Example: A[J[]={{4,5, 6), { 5,3, 2}, { 4, 2, 5}};
Sum of even elements = 4+6+2+4+2 =18
Sum of odd elements= 5+5+3+5=18