Sponsored Links
Ad by Google
Very common java coding interview question for freshers. You will face this question while appearing in campus interview, this type of questions in first round of technical written interview. This question is also known as homework question for some of you. In my previous post, i had shared how to check if a string contains unique characters or not at here. And also here is the list of written interview questions. Nowadays only theory is not enough for even experienced candidates almost every organizations has come up with their set of predefined written questions to check the logical ability and coding standards of candidates. So be ready with some basic practical questions..
Printing vowels
OUTPUT:
e
u
i
o
o
u
o
e
e
a
o
Printing vowels
package com.javamakeuse.poc; /** * * @author javamakeuse * */ public class Vowel { public static void vowel(String str) { String lowerCase = str.toLowerCase(); for (int i = 0; i < lowerCase.length(); i++) { if ((lowerCase.charAt(i) == 'a') || (lowerCase.charAt(i) == 'u') || (lowerCase.charAt(i) == 'o') || (lowerCase.charAt(i) == 'i') || (lowerCase.charAt(i) == 'e')) { System.out.println(str.charAt(i)); } } } public static void main(String[] args) { vowel("The quick brown fox jumps over the lazy dog"); } }
OUTPUT:
e
u
i
o
o
u
o
e
e
a
o
Sponsored Links
0 comments:
Post a Comment