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
Starting Out with Programming Logic and Design (5th Edition) (What's New in Computer Science)
Elementary Surveying: An Introduction To Geomatics (15th Edition)
SURVEY OF OPERATING SYSTEMS
Starting Out with Java: From Control Structures through Data Structures (4th Edition) (What's New in Computer Science)
Java How to Program, Early Objects (11th Edition) (Deitel: How to Program)
Introduction To Programming Using Visual Basic (11th Edition)
- //Movie.java import java.util.Arrays; public class Movie { private String movieName; private int numMinutes; private boolean isKidFriendly; private int numCastMembers; private String[] castMembers; // default constructorpublic Movie() { movieName = "Flick"; numMinutes = 0; isKidFriendly = false; numCastMembers = 0; castMembers = new String[10]; } // overloaded parameterized constructorpublic Movie(String movieName, int numMinutes, boolean isKidFriendly, String[] castMembers) { this.movieName = movieName; this.numMinutes = numMinutes; this.isKidFriendly = isKidFriendly; //numCastMember is set to array lengththis.numCastMembers = castMembers.length; this.castMembers = castMembers; } public String getMovieName() { return this.movieName; } public int getNumMinutes() { return this.numMinutes; } public boolean getIsKidFriendly() { return this.isKidFriendly; } public boolean isKidFriendly() { return this.isKidFriendly; } public int getNumCastMembers() { return this.numCastMembers; } public…arrow_forwardQuestion 2. package sortsearchassigncodeex1; import java.util.Scanner; import java.io.*; // // public class Sortsearchassigncodeex1 { // public static void fillArray(Scanner inputFile, int[] arrIn){ int indx = 0; //Complete code { arrIn[indx] = inputFile.nextInt(); indx++; } }arrow_forwardusing 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_forward
- using 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
- 40.|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_forwardpublic 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_forwardJAVA PROGRAMFILL IN THE BLANKSarrow_forward
- Main.java 1 class DictionaryEntry 2 - { 3 4 5 6 7 8 9- 10 11 12 13 14 15 String word; String definition; Dictionary Entry(String w, String def) {this word=new String (w); // Clone the strings this definition = new String(def); } class TestMyDictionary public static void main(String[] args) { } DictionaryEntry [] Dico = new DictionaryEntry [10]; Dico [0]=new Dictionary Entry("Java" "A modern object-oriented Type here to search programming language"); Dico [1]=new DictionaryEntry ("C++" "An effective object oriented programming language"); Dico [2] = new DictionaryEntry("FORTRAN, "FORTRAN stands for FORmula TRANSIation. Often used for simulation."); O JL I S Et Run O $ Outputarrow_forward1- class Excep { 2- public static void main(String[] args){ 3 try{ int arr[]=(1,2}; 4 int x = arr[1]/arr[0]-1; 6 7 catch(ArithmeticException e) 8- { 9. System.out.printin("divide by e"); 10 } 11 catch(ArrayIndexOutofBoundsException e) 12- { 13 System.out.println("wrong indexing"); 14 15 finally 16- { 17 System.out.println("Runtime error"); 18 } 19 }} 20 Answer:arrow_forwardWhat does the following code print out? class Main { public static void main (String[] args) { int [] myArray = {3, 41, 7, 12, 9, 1, 15, 11, 17}; int someInt - myMethod (myArray) ; System.out.println (someInt); private static int myMethod (int [] arr) { int number = Integer.MIN VALUE; for (int i = 0; i 0) { number - arr[i]; } return number; O 41 17 11arrow_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