What is the output of the program please answer with full explanation String str = “Java”; for (int i = 0; i < str.lengt

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899603
Joined: Mon Aug 02, 2021 8:13 am

What is the output of the program please answer with full explanation String str = “Java”; for (int i = 0; i < str.lengt

Post by answerhappygod »

What is the output of the program please answer with full explanation
String str = “Java”;
for (int i = 0; i < str.length(); i++) {
char x = str.charAt(i);
int y = 1;
for (int j = 0; j < str.length(); j++) {
if (str.charAt(j) == x && i != j) {
y++;
}
}//end of for loop (inner) System.out.println(x+ ">" + y);
}//end of for loop (outer)
please answer with full explanation
i need explanation
What Is The Output Of The Program Please Answer With Full Explanation String Str Java For Int I 0 I Str Lengt 1
What Is The Output Of The Program Please Answer With Full Explanation String Str Java For Int I 0 I Str Lengt 1 (44.92 KiB) Viewed 26 times
Q2. [6 marks] Trace the following Java code by writing the output 1. [2 marks] What is the output of the following program String str="Java"; for (int i = 0; i <str.length(); i++) { char x = str.charAt(i); int y = 1; for (int j = 0; j<str.length(); j++) { if (str.charAt(j) ==x && i !=j) { y++; } }//end of for loop (inner) System.out.println(x +""+y); }//end of for loop (outer) Output below: ***************** ********* **************
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply