What will the following
public class Checkpoint
{
public static void main (String [] args)
{
int funny = 7, serious = 15;
funny = serious % 2;
if (funny != 1)
{
funny = 0;
serious = 0;
}
else if (funny == 2)
{
funny = 10;
serious = 10;
}
else
{
funny = 1;
serious = 1;
}
System.out.println(funny + ” ” + serious};
}
}
Trending nowThis is a popular solution!
Learn your wayIncludes step-by-step video
Chapter 3 Solutions
Starting Out with Java: From Control Structures through Objects (7th Edition) (What's New in Computer Science)
Additional Engineering Textbook Solutions
Java How To Program (Early Objects)
Software Engineering (10th Edition)
Computer Systems: A Programmer's Perspective (3rd Edition)
Computer Science: An Overview (12th Edition)
Digital Fundamentals (11th Edition)
Starting Out with C++ from Control Structures to Objects (9th Edition)
- What will the following program display?public class Checkpoint{public static void main(String[] args){int num1 = 99;double num2 = 1.5;System.out.println(num1 + " " + num2);myMethod(num1, num2);System.out.println(num1 + " " + num2);}public static void myMethod(int i, double d){System.out.println(i + " " + d);i = 0;d = 0.0;System.out.println(i + " " + d);}}arrow_forwardWhat will the following program display?public class Checkpoint{public static void main(String[] args){int a = 10;decrementNum(a);}public static void decrementNum (int n){if (n > 0)DecrementNum (n - 2);elseSystem.out.println(n); }}arrow_forwardAnalyze the following code.public class Test { public static void main(String[] args) { System.out.println(m(2)); } public static int m(int num) { return num; } public static void m(int num) { System.out.println(num); }} What can you say about the above code? Does it run? Does it compile? Any output?arrow_forward
- Error in my Java code! I am not getting the intended results, here are my two classes and output. public class XXX_Course { // Initialize variables String Name; String deptCode; int roomNo; private static int courseNm=1000; int courseid; // Constructors XXX_Course() { Name = ""; deptCode = ""; roomNo = 0; } public XXX_Course(String Name, String deptCode, int roomNo) { this.Name = Name; this.deptCode = deptCode; this.roomNo = 0; } // Get and set methods. public void setName (String Name) { this.Name = Name; } public void setdeptCode (String deptCode) { this.deptCode = deptCode; } public void setroomNo (int roomNo) { this.roomNo=roomNo; } String getName() { return this.Name; } String getdeptCode() { return deptCode; } int getroomNo() { return roomNo; } int getcourseNo() { return courseNm++; } // tostring public String toString() { return "Course Name: "+ getName() + " Dept: "+ getdeptCode() + " Course Number: " + getcourseNo() + " Room "+…arrow_forwardEvaluate the JAVA code snippet below, then motivate why this is representative ofgood programming practices or not.public class pattern{public static void main(string[] args){int rows = 5;for(int i = 1; i <= rows; ++i){for(int j=1;j<=I;++j){system.out.print(“*”);}System.out.println();}}arrow_forwardpublic class worksheet3_1 { public static void main(String[] arg) { ShadowingExample example = new ShadowingExample(); example.x = 99; example.sampleMethod(); }}class ShadowingExample { int x; public void sampleMethod() { int x = 0; System.out.println("the value of local variable x = " + ………………………………………………); System.out.println("the value of instance variable x = " + …………………………………………); }} what should be written in the second print statement so that the output is: the value of instance variable x = 99 what should be written in the first print statement so that the output is: the value of local variable x = 0 options are: samplemethod.x this.x shadowingexample.x x Answer 1 Question 1arrow_forward
- Find the errors in this code: public class TstArray { public static void main(String args[]){ int a[] = {5, 4, 9}; int avg; int total; for(int i=0; i< a.length; i++){ total = 0; total += a[i]; } avg = total/a.length; } }arrow_forwardThis question was rejected from incompletion but it's completed. Answer the prompt with the following code as a guide for the main method: import java.awt.*; public class TestRectangle { public static void main(String[] args) { Rectangle r1 = new Rectangle(5, 4, 10, 17); Rectangle r2 = new Rectangle(10, 10, 20, 3); Rectangle r3 = new Rectangle(0, 1, 12, 15); Rectangle r4 = new Rectangle(10, 10, 20, 3); System.out.println("r1 = " + r1); System.out.println("r2 = " + r2); System.out.println("r3 = " + r3); System.out.println("r2 equals r1? " + r2.equals(r1)); System.out.println("r2 equals r2? " + r2.equals(r2)); System.out.println("r2 equals r3? " + r2.equals(r3)); System.out.println("r2 equals r4? " + r2.equals(r4)); System.out.println("r1 contains (6, 8)? = " + r1.contains(6, 8)); System.out.println("r2 contains (6, 8)? = " + r2.contains(6, 8));…arrow_forwardComputer Science Is there a way to rewrite this Java code differently? package application; public class Employee { private int eid; private String name; private String department; private float salary; private String mobileNo; public Employee() { super(); } public Employee(int eid, String name, String department, float salary, String mobileNo) { super(); this.eid = eid; this.name = name; this.department = department; this.salary = salary; this.mobileNo = mobileNo; } public int getEid() { return eid; } public void setEid(int eid) { this.eid = eid; } public String getName() { return name; } public void setName(String name) { this.name = name; } public String getDepartment() { return department; } public void setDepartment(String department) { this.department = department; } public float getSalary() { return salary; } public void setSalary(float salary) { this.salary = salary; } public String…arrow_forward
- public class Myclass{ private static int count=0; private int x; //} public Myclass(int i) { x=i; } public void incrementCount(){ count++; } public void printX(){ System.out.println("Value of x : "+ x); } public static void printCount(){ System.out.println("Value of Count : "+count); } } public class MyclassDemo{public static void main(String[] args){ Myclass myObject1 = new Myclass(5); Myclass myObject2 = new Myclass(7); }} what is the outputof the following java code? (Assume that following statements are written inside main) g) my Object1.setX(14); output: h) myObject1.incrementCount(); output: i) myObject1.printX(); output: j) myObject1.printCount(); output: k) myObject2.printCount(); output:arrow_forwardIdentify the method stub in the following code: public class VoltageCalc { private int inCurrent; private double inResistance; public void setValues(int i, double r) { inCurrent = i; inResistance = r; } public int getVoltage() { System.out.println("FIXME: Calc Voltage");return 0;} public static void main(String [] args) { VoltageCalc myCircuit = new VoltageCalc(); myCircuit.setValues(4, 3.15); } } Group of answer choices public void setValues(int i, double r) {...} public class VoltageCalc {...} public int getVoltage() {...} public static void main(String [] args) {...} Nextarrow_forward3. What will be the output of the following Java Program? class Test { public static void main(String args[]) { int arr[] = new int[2]; System.out.println(arr[0]); System.out.println(arr[1]); }}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