What will be the output of the following Java program?
class output
{
public static void main(String args[])
{ String s = “Hello World”;
int i = s.indexOf(‘o’);
int j = s.lastIndexOf(‘l’);
System.out.print(i + ” ” + j);
}
}
a) 4 8
b) 5 9
c) 4 9
d) 5 8
Answer: c
Explanation: indexOf() method returns the index of first occurrence of the character where as lastIndexOf() returns the index of last occurrence of the character.
output:
4 9
Related Posts
Which of the following is the most complete cloud computing service model?
Rackspace Cloud Service is an example of _____________
Amazon Web Services offers a classic Service Oriented Architecture (SOA) approach to ______________
_______ provides virtual machines, virtual storage, virtual infrastructure, and other hardware assets.
__________ is the most refined and restrictive service model.
Which of the following can be considered PaaS offering?
Point out the wrong statement.
Join The Discussion