Database System Concepts
7th Edition
ISBN: 9780078022159
Author: Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher: McGraw-Hill Education
expand_more
expand_more
format_list_bulleted
Question
Java
Trace through the method and determine what it does. Also draw the activation record. Thanks
1. What (2)
public static int what (int x) {
if (x <= 0) throw new IllegalArgumentException();
if (x == 1)
return 0;
int temp = what (x / 2);
return 1 + temp;
}
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by stepSolved in 2 steps
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Similar questions
- Write in Java a code give out what is on the image. Essentially write in the main function so that it prints what is in the image. Im stuck at that part it would be much appreciated if you could help. package javaapplication31; import java.util.Random;import java.util.Scanner;/**** @author */public class JavaApplication31 {String name;/*** @param args the command line arguments*/public static void main(String[] args) {int totalScore = 300;int itrcount =12;int reward;char direction;int x = 0;int y = 0;System.out.println(reward());System.out.println(inputDirection());}public static void displayInfo(int x, int y, int itrCount, int totalScore){x = 0;y = 0;itrCount = 0;totalScore =300;System.out.println("");}public static boolean doesExceed (int x,int y, char direction){return (y > 4 && Character.toLowerCase(direction) == 'u' || x < 0 && Character.toLowerCase(direction) == '1'||y < 0 && Character.toLowerCase(direction) == 'd' || x > 4 &&…arrow_forwardPlease Solve it in javaarrow_forward1 import java.util.Scanner; 3 public class TriangleArea { INM&567 000 2 4 8 9 10 11 12 13 14 15 4567890 16 17 18 19 20 21 } public static void main(String[] args) { Scanner scnr = new Scanner(System.in); } Current file: TriangleArea.java = Triangle triangle1 new Triangle(); Triangle triangle2 = new Triangle(); // TODO: Read and set base and height for triangle1 (use setBase() and setHeight()) // TODO: Read and set base and height for triangle2 (use setBase() and setHeight()) System.out.println("Triangle with smaller area:"); // TODO: Determine smaller triangle (use getArea()) // and output smaller triangle's info (use printInfo())arrow_forward
- Hi I want to create a JAVA program that will allow me to create a canvas (specifically in eclipse). Can someone straighten my code import java.awt.*;import javax.swing.*;class Main extends JFrame { // constructor Main() { super("canvas"); // create a empty canvas Main c = new Main() { // paint the canvas public void paint(Graphics g) { // set color to red g.setColor(Color.red); // set Font g.setFont(new Font("Bold", 1, 20)); // draw a string g.drawString("This is a canvas", 100, 100); } }; // set background c.setBackground(Color.black); add(c); setSize(400, 300); show(); } // Main Method public static void main(String args[]) { Main c = new Main(); }} ReplyForwardarrow_forwardCode completion and explain. public class X { public static void main(String [] args) { try { badMethod(); System.out.print("A"); } catch (RuntimeException ex) /* Line 10 */ { System.out.print("B"); } catch (Exception ex1) { System.out.print("C"); } finally { System.out.print("D"); } System.out.print("E"); } public static void badMethod() { throw new RuntimeException(); } }.arrow_forwardJAVA CODE: check outputarrow_forward
- Please help me with my assignment for computer science as I had all the dialog box pop up for me except for "Whew" what am I doing wrong? I am including with this message the coding block for the assignment. import java.awt.event.*;import javax.swing.*;public class MouseWhisperer extends JFrame implements MouseListener {MouseWhisperer() {super("COME CLOSER");setSize(300,100);setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);addMouseListener(this);setVisible(true);}public void mouseClicked(MouseEvent e) { setTitle("OUCH"); }public void mousePressed(MouseEvent e) { setTitle("LET GO"); }public void mouseReleased(MouseEvent e) { setTitle("WHEW"); }public void mouseEntered(MouseEvent e) { setTitle("I SEE YOU"); }public void mouseExited(MouseEvent e) { setTitle("COME CLOSER"); }public static void main(String[] args) { new MouseWhisperer(); }} Please advice.arrow_forwardScala programmingarrow_forwardimport java.util.Scanner; public class leapYearLab { public static void main(String[] args) { Scanner scnr = new Scanner(System.in); int userYear; boolean LeapYear; System.out.println("Enter the year"); userYear = scnr.nextInt(); isLeapYear(userYear); //if leap year if (isLeapYear){ System.out.println(userYear + " - leap year"); } else{ System.out.println(userYear + " - not a leap year"); } scnr.close(); } public static boolean isLeapYear(int userYear){ boolean LeapYear; /* Type your code here. */ if ( userYear % 4 == 0) { // checking if year is divisible by 100 if ( userYear % 100 == 0) { // checking if year is divisible by 400 // then it is a leap year if ( userYear % 400 == 0) LeapYear = true; else LeapYear = false; } // if the year is not divisible by 100 else…arrow_forward
- JAVA programming languagearrow_forwardCorrect and detailed answer will be Upvoted else downvoted. Thank you!arrow_forwardCreate a UML class diagram of the application illustrating class hierarchy, collaboration, and the content of each class. There is only one class. There is a main method that calls four methods. I am not sure if I made the UML Class diagram correct. import java.util.Random; // import Random packageimport java.util.Scanner; // import Scanner Package public class SortArray{ // class name public static void main(String[] args) { //main method Scanner scanner = new Scanner(System.in); // creates object of the Scanner classint[] array = initializeArray(scanner); System.out.print("Array of randomly generated values: ");displayArray(array); // Prints unsorted array sortDescending(array); // sort the array in descending orderSystem.out.print("Values in desending order: ");displayArray(array); // prints the sorted array, should be in descending ordersortAscending(array); // sort the array in ascending orderSystem.out.print("Values in asending order: ");displayArray(array); // prints the…arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- 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
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education