Introduction to Java Programming and Data Structures, Comprehensive Version (11th Edition)
Introduction to Java Programming and Data Structures, Comprehensive Version (11th Edition)
11th Edition
ISBN: 9780134670942
Author: Y. Daniel Liang
Publisher: PEARSON
bartleby

Videos

Textbook Question
Book Icon
Chapter 9.9, Problem 9.9.3CP

In the following code, radius is private in the Circ1e class, and myCirc1e is an object of the Circ1e class. Does the highlighted code cause any problems? If so, explain why.

public class Circle {

private double radius= 1 ;

/ ** Find the area of this circle */

public double getArea () {

return radius * radius * Math.PI;

}

public static void main(String[] args) {

Circle myCircle = new Circle();

System.out.println("Radius is" + myCircle.radius);

}

}

Blurred answer
Students have asked these similar questions
How do I change the code so if numMinutes is zero then the number cast members is also zero? Code: import java.util.*; import java.util.Arrays; public class Movie { private String movieName; private int numMinutes; private boolean isKidFriendly; private int numCastMembers; private String[] castMembers; // default constructor public Movie() { this.movieName = "Flick"; this.numMinutes = 0; this.isKidFriendly = false; this.numCastMembers = 0; this.castMembers = new String[10]; } // overloaded parameterized constructor public Movie(String movieName, int numMinutes, boolean isKidFriendly, String[] castMembers) { this.movieName = movieName; this.numMinutes = numMinutes; this.isKidFriendly = isKidFriendly; this.numCastMembers = castMembers.length; this.castMembers = new String[numCastMembers]; for (int i = 0; i < castMembers.length; i++) { this.castMembers[i] = castMembers[i]; } } // set the number of minutes public void setNumMinutes(int numMinutes) { this.numMinutes = numMinutes; } //…
// Makes String comparisons public class DebugSeven1 { publicstaticvoidmain(String[] args) { String name1 ="Roger"; String name2 ="Roger"; String name3 ="Stacy"; if(name1.equals(name2)) System.out.println(name1 + " and " + name2 + " are the same"); if(name1.equals(name3)) System.out.println(name1 + " and " + name2 + " are the same"); if(name1.equals("roger)); System.out.println(name1 + " and 'roger' are the same"); if(name1.equals("Roger")); System.out.println(name1 + " and 'Roger' are the same"); } }
This class contains a number of syntax and semantic errors.Your job is to find them all. public Class DebugMe{     public static void main(String args[]){         printSums(args);        compareBoxes();    }     //This function is designed to print the sums of all numbers between 1 and the    //first number entered as an argument to DebugMe    //For example, if you enter:  DebugMe 3    //You should get:    //    The sum of the first 1 numbers is 1.    //  The sum of the first 2 numbers is 3.    //  The sum of the first 3 numbers is 6.     public static void printSums(String[] args){    {         int count;         count = Integer.parseInt(args);         for (i = 1 ; i <= count ; i++);        {            int sum = 0;            int i = 0;            sum += i - 1;            System.out.println("The sum of the first " + i + " numbers is " + sum + ".");        }    }     //This function demonstrates the use of the Box class    //DO NOT change anything in this function    //use it to…

Chapter 9 Solutions

Introduction to Java Programming and Data Structures, Comprehensive Version (11th Edition)

Ch. 9.5 - Prob. 9.5.5CPCh. 9.5 - What is wrong in the following code? 1. class Test...Ch. 9.5 - Prob. 9.5.7CPCh. 9.6 - Prob. 9.6.1CPCh. 9.6 - Prob. 9.6.2CPCh. 9.6 - Which packages contain the classes Date, Random,...Ch. 9.7 - Suppose the class F is defined in (a). Let f be an...Ch. 9.7 - Prob. 9.7.2CPCh. 9.7 - Can you invoke an instance method or reference an...Ch. 9.9 - Prob. 9.9.1CPCh. 9.9 - Prob. 9.9.2CPCh. 9.9 - In the following code, radius is private in the...Ch. 9.10 - Prob. 9.10.1CPCh. 9.10 - Show the output of the following program: public...Ch. 9.10 - Show the output of the following code:Ch. 9.10 - Prob. 9.10.4CPCh. 9.11 - What is wrong in the following code? 1public class...Ch. 9.12 - If a class contains only private data fields and...Ch. 9.12 - If all the data fields in a class are private and...Ch. 9.12 - Is the following class immutable? public class A {...Ch. 9.13 - What is the output of the following program?...Ch. 9.14 - Prob. 9.14.2CPCh. 9.14 - Prob. 9.14.3CPCh. 9 - (The Rectangle class) Following the example of the...Ch. 9 - (The Stock class) Following the example of the...Ch. 9 - (Use the Date class) Write a program that creates...Ch. 9 - Prob. 9.4PECh. 9 - (Use the GregorianCa1endar class) Java API has the...Ch. 9 - (Stopwatch) Design a class named StopWatch. The...Ch. 9 - (The Account class) Design a class named Account...Ch. 9 - (The Fan class) Design a class named Fan to...Ch. 9 - (Geometry: n-sided regular polygon) In an n-sided...Ch. 9 - Prob. 9.10PECh. 9 - (Algebra: 2 2linear equations) Design a class...Ch. 9 - (Geometry: intersecting point) Suppose two line...Ch. 9 - (The Location class) Design a class named Location...

Additional Engineering Textbook Solutions

Find more solutions based on key concepts
True or False: To calculate the total number of iterations of a nested loop, add the number of iterations of al...

Starting Out with Java: From Control Structures through Objects (7th Edition) (What's New in Computer Science)

List four activities of a typical operating system.

Computer Science: An Overview (12th Edition)

What is the general problem with static scoping?

Concepts Of Programming Languages

The ________ object is assumed to exist and it is not necessary to include it as an object when referring to it...

Web Development and Design Foundations with HTML5 (9th Edition) (What's New in Computer Science)

Knowledge Booster
Background pattern image
Computer Science
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
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Text book image
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Text book image
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
Text book image
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Text book image
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Text book image
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education
Memory Management Tutorial in Java | Java Stack vs Heap | Java Training | Edureka; Author: edureka!;https://www.youtube.com/watch?v=fM8yj93X80s;License: Standard YouTube License, CC-BY