Computer Applications
The output of a program which extracts a part of the string "COMPASSION" is as follows:
(a) "PASS"
(b) "PASSION"
Write appropriate Java statements to get the above outputs.
Java String Handling
3 Likes
Answer
(a) "COMPASSION".substring(3, 7);
(b) "COMPASSION".substring(3);
Answered By
1 Like
Related Questions
Cyber police wanted to investigate a case; they wanted to check a list of phone numbers that had 945 anywhere in the phone number. Example: 7394567938, 7685483945.., a method was created to convert the phone number in long data type to a string and check for the existence of the number 945. Fill in the blanks (a) and (b) in the given method with appropriate Java statements:
void check(long pno) { String s = _______(a)_________; if(______(b)_______) System.out.println(pno); }A manager wants to check the number of employees with names ending with KUMAR, and fill in the blanks in the given program segment with appropriate Java statements:
void count(String s[]) { int i, l=_________, c=0; for(i=0;i<l;i++) { if(________________) c++; } System.out.println(c); }Give the output of the following program segment:
for(k=a;k<=a*b;k+=a) { if (k%b==0) break; } System.out.println(k);Give the output when a = 6, b = 4.
Kamal wants to display only the alphabets stored in a character array. While compiling the code, an error was displayed. Check for the statement with the error and write the correct statement.
char arr[]={'4', '&', 'a', 'w', 'd'}; int i; for(i=0;i<arr.length;i++) { if(Character.isLetter(arr)) System.out.println(arr); }