X_comp_EVII_24_25
X_comp_EVII_24_25
X_comp_EVII_24_25
Page 1 of 7
(x) Which of the following is an invalid literal?
1. “899” 2. 24D 3. ‘CHALK’ 4. ‘\u0000’
(a) 1 and 2 (b) Only 2 (c) Only 3 (d) 3 and 4
(xi) Which among the following is not a component of a method?
(a) Method name (b) Data members (c) return statement (d) Parameters
(xii) Once a function is defined, it can be invoked repeatedly. What is this feature
called?
(a) Reusability (b) Restructuring (c) Interface (d) All of
these
(xiii) Which of the following is not a jump statement?
(a) return (b) continue (c) break (d) None of these
(xiv) Predict the output:
System.out.println("MS EXCELSPREADSHEET".substring(3,8).toLowerCase());
(a) ms (b) excel (c) ms excel (d) sheet
(xvi) Identify the operator that gets the lowest precedence among the following:
?: , * , ==, =
(a) = (b) * (c) ?: (d) ==
(xvii) Assertion (A): We always specify the class-name as the return type of a function.
Reason (R): A function can return an object as well.
(a) Both Assertion (A) and Reason (R) are true and Reason (R) is a correct explanation
of Assertion (A)
(b) Both Assertion (A) and Reason (R) are true and Reason (R) is not a correct
explanation
of Assertion(A)
(c) Assertion (A) is true and Reason (R) is false
Page 2 of 7
(d) Assertion (A) is false and Reason (R) is true
(xviii) The first line of the method definition is termed as:
(a) Method prototype (b) Method signature (c) None of these (d) Both a and b
(xix) String s = “@snvinternational”; then s.lastIndexOf(‘P’) results in:
Page 3 of 7
{
System.out.println(c*f);
f = f + 2;
}
ix. Analyze the following iterative structure and answer the questions with working:
int a = 10, b = 20;
while(++a<=20 || ++b<=30)
{
if(a%7==0 && b%8==0)
break;
System.out.println(a + " " + b);
}
(a) How many times will the loop get executed ?
(b) What will be the output ?
x. State the output of the following code if the input value of x is (i) 10 (ii)11
if(x++==11)
System.out.println(“Result is 11”);
else if(++x==10)
System.out.println(“Result is 10”);
else if(--x==10)
System.out.println(“Result is 10”);
else
System.out.println(“Result is neither 10 nor 11”);
Question 4 [15]
Define a class to accept a string in uppercase. Now create and display a new string
by replacing each vowel by the immediate next letter and every consonant by the
immediate previous letter while the other characters remain the same.
Example:
Input: ROYAL@ATS21
Output: QPXBK@BSR21
Question 5 [15]
Write a program to overload a method NewString( ) as follows :
(i) void NewString( String s1, char ch1, char ch2) with one string argument and two-
character arguments, it replaces the character argument ch1 with the character
argument ch2 of the string s1 and prints the new string.
Example
Sample Input : Input value string s1 as : “PROGRAM”
Input ch1 as : ‘R’
Input ch2 as : ‘S’
Sample Output : PSOGSAM
Page 5 of 7
(ii) void NewString(String s2) with one string argument, method prints the position of
the first space and the position of last space of the given string s2
Sample Input :
Enter the string as: “Artificial Intelligence is everywhere”
Sample Output :
First space : 10
Last Space : 27
(iii) void NewString(String s1, String s2) : To verify and display whether the two
strings
given as arguments are identical or not.
Question 6
Write a program to generate the following patterns [15]
a) C * * * * *
CL # # # #
CLA ***
CLAS # #
CLASS *
Page 6 of 7
The original number 126 is completely divisible by 7. So, 126 is a Jupiter number.
Page 7 of 7