Concept explainers
a)
Explanation of Solution
Given code:
//declare the class showerrors
public class ShowErrors {
// main method
public static void main(String[] args) {
// create and initialize object
ShowErrors t = new ShowErrors(5);
}
}
Error in the code:
-
...
b)
Explanation of Solution
Given code:
//define the class showErrors
public class ShowErrors {
// define the main method
public static void main(String[] args) {
// new object gets created
ShowErrors t = new ShowErrors();
// object access method x
t...
c)
Explanation of Solution
Given code:
//new class gets defined
public class ShowErrors
{
//define the method
public void method1()
{
//circle class with object c
Circle c;
//display the radius
System.out.println("What is radius " +
c...
d)
Explanation of Solution
Given code:
//new class showerror gets defined
public class ShowErrors {
// define the main method
public static void main(String[] args) {
// class c and object gets initialized
C c = new C(5.0);
// display the value of c
System.out.println(c.value);
}
}
// class c
class C {
// assign the value
int valu...
Trending nowThis is a popular solution!
Chapter 9 Solutions
Introduction to Java Programming and Data Structures, Comprehensive Version Plus MyProgrammingLab with Pearson EText -- Access Card Package
- DO NOT USE EXISTING ANSWERS ON CHEGG OR COURSE HERO OR ANY OTHER SERVICES PLEASE! Thanks :) CODE IN PYTHON AND SHOW COMMENTS TO EXPLAIN CODE A confused Dutchman trying to speak English could say “I am in the war”, even though there is no hostile activity going on. The confusion1 here is that the English sentence “I am confused” is translated in Dutch as “Ik ben in de war”, which is phonetically (“sounding”) quite close to the first sentence. Such confusion leads to much enjoyment, but can complicate matters a bit. Given a sentence in Dutch and a dictionary containing both correct translations as well as phonetic (incorrect) translations of individual words, find the translation of the sentence and indicate whether it is correct, or in case there is more than one find the total number of correct and incorrect translations. A sentence is correctly translated when each word of the sentence is correctly translated. Input The input consists of: One line with an integer n (1≤n≤20), the…arrow_forwardWhat would be the output of the following python code?arrow_forwardQUESTION One of the downsides of using expressions that produce results other than true or false is it is expensive to type-check it hurts readability since it may be confusion to know which route an execution will take. it can cause side effects skewing the results of the rest of the code it hurts writability since we have to write such long expressions.arrow_forward
- Please write clearly, thank youarrow_forwardWhat is the output from each of the following pseudocode statements?arrow_forwardQuestions:1. A criticism of the break and continue statements is that each is unstructured. These statements can always be replaced by structured statements. Describe in general how you’d remove any break statement from a loop in a program and replace it with some structured equivalent. [Hint: The break statement leaves a loop from within the body ofthe loop. Another way to leave is by failing the loop-continuation test. Consider using in theloop-continuation test a second test that indicates “early exit because of a ‘break’ condition.”] Use the technique you developed here to remove the break statement from the program of Fig. 5.13. 2. Write a program that uses for statements to print the following patterns separately, one below the other. Use for loops to generate the patterns. All asterisks (*) should be printed by a single statement of the form cout << '*'; (this causes the asterisks to print side by side). [Hint: The last two patterns require that each line begin with an…arrow_forward
- C++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage Learning