Find the output of the following code blocks Q3: public class test23 { public static void main(String[]
Fantastic news! We've Found the answer you've been seeking!
Question:
Find the output of the following code blocks
Transcribed Image Text:
Q3: public class test23 { public static void main(String[] args) { int x,m; X=10 m=2 if(m==0) { x= x+2; System.out.println("X=" +x); } else if(m==1) { x= x+4; System.out.println("X=" +x); } if(m==2) { x= x+6; System.out.println("X=" +x); } [Rubrics: 2 marks for the fully correct output, 0 mark for wrong output] Q3: public class test23 { public static void main(String[] args) { int x,m; X=10 m=2 if(m==0) { x= x+2; System.out.println("X=" +x); } else if(m==1) { x= x+4; System.out.println("X=" +x); } if(m==2) { x= x+6; System.out.println("X=" +x); } [Rubrics: 2 marks for the fully correct output, 0 mark for wrong output]
Expert Answer:
Answer rating: 100% (QA)
Lets analyze the code step by step int x m declares two integer variables x and m x 10 initializes t... View the full answer
Related Book For
Building Java Programs A Back To Basics Approach
ISBN: 9780135471944
5th Edition
Authors: Stuart Reges, Marty Stepp
Posted Date:
Students also viewed these programming questions
-
How do you simplify the max method in the following, using the conditional operator? 1: /** Return the max of two numbers */ 2: public static int max ( int num1, int num2 ) { 3: int result; 4: 5: if...
-
9.1 Exercise (JDK Source Code): Extract the source code of the class Math from the JDK source code ("$JAVA_HOME" "src.zip" "Math.java" under folder "java.lang"). Study how constants such as E and...
-
Declare and assign these variables as shown (all your code must appear in the body of the main method): String firstName = "Blueberry"; String lastName = "Strawberry"; In addition, declare and...
-
Question B3 [2 points]. Examine, analytically and graphically in a diagramme drawn in the PD-z space, the effects of the increase in i*, and show that in the new equilibrium domestic prices can be...
-
1. A proton enters a uniform magnetic field that is perpendicular to the proton's velocity (Fig. 20-51).What happens to the kinetic energy of the proton? (a) It increases. (b) It decreases. (c) It...
-
What is the Securities and Exchange Commission (SEC), and what is its role in external financial reporting?
-
Prepare closing entries. Requirements 1. Using the following selected accounts of A to Z Electrical, Inc., at April 30, 2010, prepare the entitys closing entries: 2. What is A to Z Electricals ending...
-
Phil and Marcy have been married for a number of years. Marcy is very wealthy, but Phil is not. In fact, Phil, who has only $10,000 of property, is very ill, and his doctor believes that he probably...
-
Identify business opportunities and how they avoid mistakes. Please give examples.
-
Using the data in the student spreadsheet file Ethan Allen Financials.xlsx (to find the student spreadsheets for Financial Analysis with Microsoft Excel, ninth edition, go to...
-
Barlow Company manufactures three productsA, B, and C. The selling price, variable costs, and contribution margin for one unit of each product follow: A Product B Selling price Variable expenses:...
-
ter 6+72 Divide: Write your answer in a + bi form 3+5i
-
When light of wavelength190nm falls on acesiumsurface, electrons having a maximum kinetic energy of 4.39eV are emitted. Find values for the following. (a) the work function of cesium eV? (b) the...
-
Calculate the Present Value of the Total Cost of Risk for the next two years in the following scenario. Fast Delivery is a regional transport service. The Risk Manager of Fast Delivery considers...
-
Discuss the relationship between sustainability and corporate social responsibility (CSR), addressing how companies can integrate sustainability goals into their business strategies, stakeholder...
-
What are some strategies to make use of Opportunities to minimize the Weaknesses of the company Revlon? What are some strategies to minimize the potential dangers lying in sectors where Weaknesses...
-
PeterCo has the following Government Bonds: a-Complete the following table PeterCo Bonds % YTM, maturity=10Years S&P Rating Order from most secure (1) to least (5) Mark with x the Junk Bonds A...
-
Suppose you need to answer any four of seven essay questions on a history test and you can answer them in any order. a. How many different question combinations are possible? b. What is the...
-
Write a method called lastIndexOf that accepts an integer as a parameter and returns the index in the list of the last occurrence of that value, or -1 if the value is not found in the list. For...
-
Which of the following choices is the correct syntax for declaring a real number variable named grade and initializing its value to 4.0 ? a. int grade: 4.0; b. grade = double 4.0; c. double grade =...
-
There are two mistakes in the following code, which attempts to draw a line from coordinates (50, 86) to (20, 35). What are they? DrawingPanel panel = new DrawingPanel(200, 200); panel.drawLine(50,...
-
a. Examine how each of the following affects the natural unemployment rate. (i) The discovery of new energy resources lowers the price of energy, stimulating more industrial activities. (ii) The...
-
In a particular economy the negative oil price shock occurs in two different time periods, say 1990-1995 and 2000-2005. Assume that these two oil price shocks are similar in nature. Given the same...
-
In this problem you are asked to show that the expectations-augmented Phillips curve (derived in the text using the extended classical model) can be derived using the Keynesian model. Consider a...
Study smarter with the SolutionInn App