What will be the output of the following Java program?
class output
{
public static void main(String args[])
{
String a = “hello i love java”;
System.out.println(a.indexOf(‘e’)+” “+a.indexOf(‘a’)+” “+a.lastIndexOf(‘l’)+” “+a.lastIndexOf(‘v’));
}
}
a) 6 4 6 9
b) 5 4 5 9
c) 7 8 8 9
d) 1 14 8 15
Answer: d
Explanation: indexof(‘c’) and lastIndexof(‘c’) are pre defined function which are used to get the index of first and last occurrence of
the character pointed by c in the given array.
Output:
1 14 8 15
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