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
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 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_forwardpublic 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_forward
- class 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_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 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_forward
- class 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_forwardpublic class Test { } public static void main(String[] args) { String str = "Salom"; System.out.println(str.indexOf('t)); }arrow_forwardpublic class Test { } public static void main(String[] args){ int a = 10; System.out.println(a*a--); }arrow_forward
- Kindly fix this error for me import java.io.IOException;public class MazeTest {public static void main(String[] args) throws IOException {MazeSolver solver = new MazeSolver("maze2.txt");solver.displayMaze(); // Display initial state of the mazesolver.solveMaze(); // Solve the maze using DFS}} Error: C:\Users\adamu\IdeaProjects\MazeSolver.java\src\MazeTest.java:6:15java: cannot find symbol symbol: method displayMaze() location: variable solver of type MazeSolverarrow_forwardIn C++ class rectangleType { public: void setLengthWidth(double x, double y); //Sets the length = x; width = y; void print() const; //Output length and width double area(); //Calculate and return the area of the rectangle (length*width) double perimeter(); //Calculate and return the perimeter (length of outside boundary of the rectangle) private: double length; double width; }; Declare an instance of rectangleType.arrow_forwardIn C++ class rectangleType { public: void setLengthWidth(double x, double y); //Sets the length = x; width = y; void print() const; //Output length and width double area(); //Calculate and return the area of the rectangle (length*width) double perimeter(); //Calculate and return the perimeter (length of outside boundary of the rectangle) private: double length; double width; }; Print out the area of the rectangle.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