Menu
Topics Index
...
`

Boolean logical operators and creating Method


If you need explanation Read this topic

If you need Answer Take test on this topic

Boolean logical operators and creating Method
What will be the output of the following program?
public class isVowel
{
    public static boolean isVowel(String s)
    {
        s = s.toLowerCase();
        return s.equals("a") || s.equals("e") || s.equals("i") || s.equals("o") || s.equals("u");
    }
    public static void main(String args[])
    {
        System.out.println(isVowel("A"));
    }
}

A. true
B. false
C. Compilation Error
D. Runtime Error
Topic: Conclusion Of Strings In Java

If you need explanation Read this topic

If you need Answer Take test on this topic

User comments below. All of them might not be correct.

ANS IS A (true)

Above program is used to determine whether the given letter is a vowel or not by returning true or false...

--Function isVowel() is used which is passed one parameter String s.

--Then that String is converted to Lowercase by toLowerCase() function available in String class.

--After that that LowerCased letter is compared with 'a,'e','i','o' and 'u' if the letter is equal it returns true.

--Here 'A' is passed and converted to 'a' which is equal to 'a' thats why equal returns true.

Posted by Mânïshå Mùlchåndânï    2014-12-29 12:59:52


This dose is now closed and the winners are Mânïshå Mùlchåndânï,  for 'First Correct Comment', Sai Ram,  for 'Best Comment' and Sai Ram for the 'Popular Comment'. The 'lucky liker' is Puneeth Shivalingaiah. Please login into Merit Campus using facebook, to claim your recharge. Go to http://java.meritcampus.com/earnings to raise the recharge.

Posted by Merit Campus    2014-12-30 04:48:11


© meritcampus 2019

All Rights Reserved.

Open In App