Show the output of the following code:
import java.uti1.* ;
public class Test {
public static void main(String[] args) {
List<String> list =
Arrays.asList(“yellow”, “red”, “green”, “blue”);
Collections.reverse(list);
System.out.println(list);
List<String> list1 =
Arrays.asList(“yellow”, “red”, “green”, “blue”);
List<String> list2 = Arrays.asList(“white”, “black”);
Collections.copy(list1, 1ist2);
System.out.println(list1);
Collection<String> c1 = Arrays.asList ( “red”, “cyan”);
Collection<String> c2 = Arrays.asList(“red”, “blue”);
Collection<String> c3 = Arrays.asList(“pink”, “tan”);
System.out.println(Collections.disjoint(c1, c2));
System.out.println(Collections.disjoint(c1, c3));
Collection<String> collection =
Arrays.asList(“red”, “cyan”, “red”);
System.out.println(Collections.frequency(collection, “red”));
}
}
Want to see the full answer?
Check out a sample textbook solutionChapter 20 Solutions
Introduction to Java Programming and Data Structures, Comprehensive Version (11th Edition)
Additional Engineering Textbook Solutions
Introduction To Programming Using Visual Basic (11th Edition)
Java How to Program, Early Objects (11th Edition) (Deitel: How to Program)
Java How To Program (Early Objects)
Database Concepts (8th Edition)
Software Engineering (10th Edition)
Starting Out with Java: From Control Structures through Data Structures (4th Edition) (What's New in Computer Science)
- using System; class main { publicstaticvoid Main(string[] args) { int number = 1; while (number <= 88) { int i; Random r = new Random(); int[] randNo=newint[3]; for(i=0;i<3;i++) { randNo[i]= r.Next(1,88); Console.WriteLine("Random Number between 1 and 88 is "+randNo[i]); } } } } This code is supposed to count from 1-88 and then select three random numbers from the list but instead it generates an infinite loop of random numers between 1-88. how can it be fixed?arrow_forwardusing System; class main { publicstaticvoid Main(string[] args) { int number = 1; while (number <= 88) { int i; Random r = new Random(); int[] randNo=newint[3]; for(i=0;i<3;i++) { randNo[i]= r.Next(1,88); Console.WriteLine("Random Number between 1 and 88 is "+randNo[i]); } } } } how can this program be fixed to count from 1-88 and then choose 3 different random numbers?arrow_forwardpublic static void main(String[] args) { int a; int b; int c; c = quad(0,1, 2); b = quad(1, 2, 3); a = quad(5, 6, 7); c = c +b+ a; } private static int quad(int a, int b, int c) { int r; r= a +b+ c; return r; } For the code above, how many entries does the activation record for method quad have? During the execution of main, at most how many activation records are existent on the run-time stack?arrow_forward
- using System; class main { publicstaticvoid Main(string[] args) { Random r = new Random(); string[] ROYGBIV; ROYGBIV = new string[7] {"Red", "Orange", "Yellow", "Green", "Blue", "Indigo", "Violet"}; int randNo= r.Next(0,6); Console.Write("Hi, my name is Stevie. I am thinking of Rainbow colors.\nGuess which color I am thinking of? "); string guessedColor = Console.ReadLine(); do { if(guessedColor != ROYGBIV[randNo]) { Console.WriteLine("Your guess is NOT correct.Please enter another color"); guessedColor = Console.ReadLine(); } if(guessedColor == ROYGBIV[randNo]) { Console.WriteLine("You guessed correctly!"); } }while(guessedColor != ROYGBIV[randNo]); } } Hello! This program is written in C# to play a guessing game with the user but instead of numbers its with the colors of the rainbow. How can it be changed to the letters of the entire alphabet instead?arrow_forwardusing System; class main { publicstaticvoid Main(string[] args) { Random r = new Random(); string[] Animal; Animal = new string[4] {"dog","cat","mouse","rhino"}; int randNo= r.Next(0,3); Console.Write("Hi, my name is Stevie. I am thinking of an Animal.\nGuess which Animal I am thinking of? "); string guessedColor = Console.ReadLine(); do { if(guessedColor != Animal[randNo]) { Console.WriteLine("Your guess is NOT correct.Please enter another color"); guessedColor = Console.ReadLine(); } if(guessedColor == Animal[randNo]) { Console.WriteLine("You guessed correctly!"); } }while(guessedColor != Animal[randNo]); } } Hello! This program is in C# to play a guessing game with the user. How can it be modified to have the user spell out the words?arrow_forwardX2, Y2------1.arrow_forward
- // JAVA program to calculate the average score // import utility class for list collectionimport java.util.*; // class definitionpublic class Main{// main methodpublic static void main(String[] args) { // Variable declarationchar middle_initial;int id;double score1, score2, score3, average;String first_name, last_name, choice; // Scanner to read user inputsScanner sc = new Scanner(System.in); // integer counter to count number of studentsint counter = 0; // run a do-while loop until the user enters N or Nodo{// prompt user to enter first name, middle initial, and last nameSystem.out.print("Enter student's First Name:");first_name = sc.next();System.out.print("Enter student's Middle Initial:");middle_initial = sc.next().charAt(0);System.out.print("Enter student's Last Name:");last_name = sc.next(); // Add fullName of student in the Name listName.add(first_name + "." + middle_initial + "." + last_name); // enter idSystem.out.print("Enter student's Id:");id = sc.nextInt(); // add Id…arrow_forward// SuperMarket.java - This program creates a report that lists weekly hours worked // by employees of a supermarket. The report lists total hours for // each day of one week. // Input: Interactive // Output: Report. import java.util.Scanner; public class SuperMarket { public static void main(String args[]) { // Declare variables. final String HEAD1 = "WEEKLY HOURS WORKED"; final String DAY_FOOTER = " Day Total "; // Leading spaces are intentional. final String SENTINEL = "done"; // Named constant for sentinel value. double hoursWorked = 0; // Current record hours. String hoursWorkedString = ""; // String version of hours String dayOfWeek; // Current record day of week. double hoursTotal = 0; // Hours total for a day. String prevDay = ""; // Previous day of week. boolean done = false; // loop control Scanner input = new…arrow_forward40.|Asiacell docs.google.com/forms :D yuustivi بل اجابة هذا السؤال بشكل PDF Describe the difference between tl .following two progran class Progarml { public static void main(String[] args) { int[] a = {1, 2}: q3(a); System.out.println( a[0]+ " " +a[1]);} class Program2 { public static void main(String[] args) { int[] a = {1, 2}; q3(a[0], a[ 1]); System.out.println(a[0]+ " "+ a[1]);} static void swap(int[] a) { int t = a[0]: a[0] = a[1]: a[1] = t:} static void q3(int n1, int n2) { int t =n1; nl = n2; n2 = t;} إضافة ملف 4 صفحة 3 من التالي Es ل كلمات المرور عبر نماذج Google مطلقًا.arrow_forward
- public class Course{String name;String dept;int number;public Course (String n, String d, int n){name = n;dept = d;number = n;}public String toString(){return "Course " + name + " in " + dept + " #: " + number;}public static void main (String [] args){Scanner in = new Scanner(System.in);add 10 lines using the scanner and saving them as strings The input for each line will be entered a String, a space, another String, and an int. Parse the input string into those three items and make an instance of Course. Add the new Course instance to a generic ArrayList of Course. print out each Course in the ArrayList.arrow_forward6. Show the printout of the following code: public class ArraysBasic { public static void main(String[] args) { int A[] = {1, 2, 3}; } System.out.println("array A: " + A[0] +""+A[1]+""+ A[2]); System.out.println("array B: " + A[0] + " " + A[1] + " " + A[2]); zeroArray(A); A = new int[5]; System.out.println("array C: " + A[0] + " " + A[1] + " " + A[3] + " " + A[4]); } } public static void zeroArray(int[] list) { for (int j = 0; j < list.length; ++j) { list[j] = 99;arrow_forwardusing System; class Program { publicstaticvoid Main(string[] args) { int number = 1; while (number <= 88) { Console.WriteLine(number); number = number + 2; } int[] randNo = newint[88]; Random r = new Random(); int i=0; while (number <= 88) { randNo[i] = number; number+=1; i+=1; } for (i = 0; i < 3; i++) { Console.WriteLine("Random Numbers between 1 and 88 are " + randNo[r.Next(1, 88)]); } } } this code counts from 1-88 in odds and then selects three different random numbers. it keeps choosing 0 as a random number everytime. how can that be fixed?arrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education