Show the output of the following code:
public class Test {
public static void main(String[] args) {
Graph<Character> graph = new UnweightedGraph<>();
graph.addVertex(‘U’);
graph.addVertex(‘V’);
int indexForU = graph.getIndex(‘U’);
int indexForV = graph.getlndex(‘V’);
System.out.println (“indexForU is ” + indexForU);
System.out.println(“indexForV is ” + indexForV);
graph.addEdge(indexForU, indexForV);
System.out.println(“Degree of U is ” +
graph.getDegree(indexForU));
System.out.println{“Degree of V is ” +
graph.getDegree(indexForV));
}
}
Want to see the full answer?
Check out a sample textbook solutionChapter 28 Solutions
Instructor Solutions Manual For Introduction To Java Programming And Data Structures, Comprehensive Version, 11th Edition
Additional Engineering Textbook Solutions
Java: An Introduction to Problem Solving and Programming (8th Edition)
Absolute Java (6th Edition)
Web Development and Design Foundations with HTML5 (9th Edition) (What's New in Computer Science)
Starting Out with Java: From Control Structures through Data Structures (4th Edition) (What's New in Computer Science)
Starting Out with Java: From Control Structures through Objects (6th Edition)
Modern Database Management (12th Edition)
- public class Polygon { private double sideLength; private int sides; private String shape; public double getArea () { int n sides; double a sideLength; return ((a * a * n) / (4 * Math.tan((180 / n) 3.14159 / 180))); public void setPolygon (double sl, int sd, String sh) { sides-sd; sideLength-sl; shape=sh; public Polygon (double sl, int sd, String sh) ( sides-sd; sideLengthsl; shape=sh; public String getShape () { return (shape); } public int getSides () { return (sides); } public double getLength () { return (sideLength); } Write a static method named find that takes as a parameter an array of type Polygon named list. The method should print the shapes of each polygon that has an area greater than 500 and return their count. The method prototype is public static int find (Polygon [] list); Note: assume the array is already declared, populated with data in the main method and ready to be used.arrow_forwardclass WaterSort { Character top = null; // create constants for colors static Character red= new Character('r'); static Character blue = new Character('b'); static Character yellow= new Character('g'); // Bottles declaration public static void showAll( StackAsMyArrayList bottles[]) { for (int i = 0; i<=4; i++) { System.out.println("Bottle "+ i+ ": " + bottles[i]); } } public static void main(String args[]) { //part 1 //create the bottle StackAsMyArrayList bottleONE = new StackAsMyArrayList<Character>(); System.out.println("\nbottleONE:"+ bottleONE+ " size:" + bottleONE.getStackSize()+" uniform? "+ bottleONE.checkStackUniform());…arrow_forwardclass overload { int x; double y; void add(int a , int b) { x = a + b; } void add(double c , double d) { y = c + d; } overload() { this.x 0; %3D this.y = 0; } %3D } class Overload_methods { public static void main(String args[]) { overload obj int a = 2; double b - 3.2; obj.add(a, a); obj.add(b, b); System.out.println(obj.x + } = new overload(); + obj.y); } #3Run the codearrow_forward
- public static void simpleLoop(int total) { String tmp = ""; for (int x = 0; x < total; x++) { tmp + (x + ","); } } } System.out.println(tmp.length()); public static void main(String[] args) { simpleLoop (2);arrow_forwardJava: ShowStudent.java: class ShowStudent { public static void main (String args[]) { Student pupil = new Student(); pupil.setIdNumber(234); pupil.setPoints(47); pupil.setHours(15); pupil.showIdNumber(); pupil.showPoints(); pupil.showHours(); System.out.println("The grade point average is " + pupil.getGradePoint()); } } ShowStudent2.java: class ShowStudent2 { public static void main (String args[]) { Student pupil = new Student(); pupil.showIdNumber(); pupil.showPoints(); pupil.showHours(); System.out.println("The grade point average is " + pupil.getGradePoint()); } } Student.java: class Student { // the private data members private int idNumber; private int hours; private int points; // Constructor added in part c Student() { } // end of constructor added in part c // the public get and set methods public void…arrow_forwardpublic class Test { } public static void main(String[] args) { String str = "Salom"; System.out.println(str.indexOf('t)); }arrow_forward
- public class Test { } public static void main(String[] args){ int a = 10; System.out.println(a*a--); }arrow_forwardclass class { public static void main(String args[]) { int a =5; int b =10; first: { second: { third: { if(a == b >>1) break second; } System.out.println(a); } System.out.println(b); } } } Give result for the code Java Try to do ASAParrow_forwardComputer Science Java Language: Provide the equivalent UML Diagram for this code. public class ClassTest { public static void main (String args[]) { TestB objB = new TestB(); TestB objC = new TestB(); Testers objA = new Testers(); objA.Display(); } }arrow_forward
- class Param3 { public int x; private void increase(int p) { x = x*p; } public void calculateX(int y) { increase(y); } public int getX() { return x; } } // in another class Param3 q3 = new Param3(); q3.x = 5; q3.calculateX(7); System.out.println(q3.getX()); what would be the answer for the last two lines ? also above were x = x*p do both x in here are the fields? wouldn't that be cnofusing?arrow_forwardpackage ch08.apps;import ch08.maps.*; public class HMapDriver { public static void main(String[] args) { boolean result; HMap<String, String> test; test = new HMap<String, String>(10,0.75); /*String s = null;test.put(s,"value");test.put("s",null);System.out.println("Expect 'null':\t" + test.get("s"));System.out.println("Expect 'true':\t" + test.contains("s"));test = new ArrayListMap<String, String>();*/ System.out.println("Expect 'true':\t" + test.isEmpty()); System.out.println("Expect '0':\t" + test.size()); System.out.println("Expect 'null':\t" + test.put("1", "One")); System.out.println("Expect 'false':\t" + test.isEmpty()); System.out.println("Expect '1':\t" + test.size()); System.out.println("Expect 'One':\t" + test.put("1", "One")); System.out.println("Expect 'false':\t" + test.isEmpty()); System.out.println("Expect '1':\t" + test.size()); test.put("2", "Two"); test.put("3", "Three");…arrow_forwardJAVA ONLY public String cleanNumber(String phoneNumber) { int digit=0; String result = ""; String number= ""; for (int i = 0; i < phoneNumber.length(); i++) { char ch = phoneNumber.charAt(i); if (Character.isDigit(ch)) { number = number + ch; digit++; } } if(digit == 10) System.out.println("("+phoneNumber.substring(1,3)+")"+"-"+phoneNumber.substring(4,6)+phoneNumber.substring(7,10)); else result = "Error"; return result; }} Argument "(444) 999-1234" Actual (44)-) 99- "" Expected "(444) 999-1234" "4449991234" (44)-99234 "" "(444) 999-1234" "444.999.1234" (44)-99.12 "" "(444) 999-1234" What am doing wrong? How can I make the actual look like the expected? What do I have to change?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