Advertisements
Advertisements
Which of the following is not true with regards to a switch statement?
Concept: undefined >> undefined
Method prototype for the method compute which accepts two integer arguments and returns true/false.
Concept: undefined >> undefined
Advertisements
Assertion(A): An argument is a value that is passed to a method when it is called.
Reason(R): Variables which are declared in a method prototype to receive values are called actual parameters.
Concept: undefined >> undefined
Rewrite the following code using single if statement.
if(code=='g')
System.out.println("GREEN");
else if(code=='G')
System.out.println("GREEN");Concept: undefined >> undefined
A student executes the following program segment and gets an error. Identify the statement which has an error, correct the same to get the output as WIN.
boolean x=true;
switch(x)
{ case 1:System.out.println("WIN");break;
case 2;System.out.println("LOOSE");
}Concept: undefined >> undefined
Write the java expression for `root3x + sqrty`
Concept: undefined >> undefined
Define a class to accept a number and check whether it is a SUPERSPY number or not. A number is called SUPERSPY if the sum of the digits equals the number of the digits.
Example1:
Input: 1021
Output: SUPERSPY number [SUM OF THE DIGITS = 1+0+2+1 = 4, NUMBER OF DIGITS = 4]
Example2:
Input: 125
Output: Not an SUPERSPY number [1+2+5 is not equal to 3]
Concept: undefined >> undefined
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.
Concept: undefined >> undefined
Write the return data type of the following function:
endsWith( )
Concept: undefined >> undefined
Write two characteristics of a constructor.
Concept: undefined >> undefined
Write a program to initialize the seven Wonders of the World along with their locations in two different arrays. Search for the name of the country input by the user. If found, display the name of the country along with its Wonder, otherwise display “Sorry Not Found!”.
Seven wonders — CHICHEN ITZA, CHRIST THE REDEEMER, TAJMAHAL, GREAT WALL OF CHINA, MACHU PICCHU, PETRA, COLOSSEUM
Locations — MEXICO, BRAZIL, INDIA, CHINA, PERU, JORDAN, ITALY
Example —
Country Name: INDIA Output: INDIA-TAJMAHAL
Country Name: USA Output: Sorry Not Found!
Concept: undefined >> undefined
Give the output of the following string methods.
"MISSISSIPPI".indexOf('S') + "MISSISSIPPI".lastIndexOf('I')
Concept: undefined >> undefined
Define a class to accept two strings, convert them into uppercase, check and display whether two strings are equal or not, if the two strings are not equal, print the string with the highest length or print the message both the strings are of equal length.
Concept: undefined >> undefined
Define a class to accept a string, convert it into lowercase and check whether the string is a palindrome or not.
A palindrome is a word that reads the same backward as forward.
Example:
madam, racecar etc.
Concept: undefined >> undefined
The keyword used to call package in the program:
Concept: undefined >> undefined
State the type of loop in the given program segment
for (int i = 5; i l = 0; i =2)
System.out.println(i);
Concept: undefined >> undefined
The String class method to join two strings is ______.
Concept: undefined >> undefined
The output of the function "COMPOSITION". substring(3, 6):
Concept: undefined >> undefined
Give the output of the following String class method:
"COMMENCEMENT".lastIndexOf('M')Concept: undefined >> undefined
Give the output of the following String class method:
"devote". compareTo("DEVOTE")Concept: undefined >> undefined
