Computer Applications
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);
}
Java String Handling
8 Likes
Answer
void count(String s[])
{
int i, l = s.length, c = 0;
for(i = 0; i < l; i++)
{
if(s[i].endsWith("KUMAR"))
c++;
}
System.out.println(c);
}
Answered By
3 Likes
Related Questions
Name the following:
(a) A Character method that checks whether a character is an alphabet or a number.
(b) A Math method that does not have an argument.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); }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.
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.