Computer Applications
Consider the following String array and give the output
String arr[]= {"DELHI", "CHENNAI", "MUMBAI", "LUCKNOW", "JAIPUR"};
System.out.println(arr[0].length() > arr[3].length());
System.out.print(arr[4].substring(0,3));
Related Questions
Give the output of the following string functions:
"ACHIEVEMENT".replace('E', 'A')Give the output of the following string functions:
"DEDICATE".compareTo("DEVOTE")Your friend is trying to write a program to find and display the frequency of vowels in a string. Due to confusion in the syntax of some of the statements, he could not complete the program and has left some places blank marked with ?1?, ?2?, ?3? and ?4? to be filled with expression/function. The incomplete program is shown below:
import java.util.*; class Vowels { public static void main(String args[]) { Scanner ...?1?... = new Scanner(System.in); String st; int i, b, v = 0; char chr; System.out.println("Enter a string"); st = ............?2?............; // to input a string st = ............?3?...........; // to convert the string into uppercase b = st.length(); for( i = 0 ; i < b ; i++) { chr = ............?4?............; // to extract a character if(chr == 'A' || chr == 'E' || chr == 'I' || chr == 'O' || chr == 'U') v = v + 1; } System.out.println("No. of Vowels = " + v); } }Based on the above discussion, answer the following questions:
(a) What expression/function will be filled in place of ?1?
(b) What expression/function will be filled in place of ?2?
(c) What expression/function will be filled in place of ?3?
(d) What expression/function will be filled in place of ?4?
Differentiate between equals() and ==