Given the following code, what will be the value of finalAmount when it is displayed? Show
public class Order public Order(int orderNumber, double orderAmt, public double finalOrderTotal() public class CustomerOrder Upgrade to remove ads Only ₩37,125/year
Terms in this set (57)An access specifier indicates how a class may be accessed. True A method that gets a value from a class's field but does not change it is known as a mutator method. False The term "no-arg constructor" is applied to any constructor that does not accept arguments. True When a local variable in an instance method has the same name as an instance field, the instance field hides the local variable. False The public access specifier for a field indicates that the field may not be accessed by statements outside the class. False The term "default constructor" is applied to the first constructor written by the author of the class. False A method that stores a value in a class's field or in some other way changes the value of a field is known as a mutator method. True A constructor is a method that is automatically called when an object is created. True The java.lang package is automatically imported into all Java programs. True Shadowing is the term used to describe where the field name is hidden by the name of a local or parameter variable. True An object can store data. True A class is not an object. It is a description of an object. True Instance methods should be declared static. False Instance methods do not have the key word static in their headers. True When an object is passed as an argument to a method, the object's address is passed into the method's parameter variable. True When an object is created, the attributes associated with the object are called __________. instance fields A class's responsibilities include __________. the things a class is responsible for knowing Data hiding (which means that critical data stored inside the object is protected from code outside the object) is accomplished in Java by __________. using the private access specifier on the class fields Methods that operate on an object's fields are called __________. instance methods A group of related classes is called a(n) __________. package Class objects normally have __________ that perform useful operations on their data, but primitive variables do not. methods You should not define a class that is dependent on the values of other class fields __________. in order to avoid having stale data Another term for an object of a class is a(n) __________. instance Which symbol indicates that a member is public in a UML diagram? + Which symbol indicates that a member is private a UML diagram? - What does the following UML diagram entry mean? + setHeight(h : double) : void a public method with a parameter of data type double that does not return a value Which of the following is not involved in identifying the classes to be used when developing an object-oriented application? the code A constructor is a method that __________. performs initialization or setup operations It is common practice in object-oriented programming to make all of a class's __________. fields private A class specifies the __________ and __________ that a particular type of object has. fields, methods __________ refers to combining data and code into a single object. Encapsulation The following statement is an example of __________. import java.util.Scanner; an explicit import statement The following statement is an example of __________. import java.util.*; a wildcard import statement After the header, the body of the method appears inside a set of __________. braces, { } One or more objects may be created from a(n) __________. class A constructor __________. has the same name as the class The scope of a private instance field is __________. the instance methods of the same class To indicate the data type of a variable in a UML diagram, you enter __________. the variable name followed by a colon and the data type Two or more methods in a class may have the same name as long as __________. they have different parameter lists The scope of a public instance field is __________. the instance methods and methods outside the class Overloading means that multiple methods in the same class __________. have the same name but different parameter lists When an object is passed as an argument to a method, what is passed into the method's parameter variable? the object's memory address A constructor __________. has the same name as the class A(n) __________ can be thought of as a blueprint that can be used to create a type of __________. class, object When you work with a __________, you are using a storage location that holds a piece of data. primitive variable A reference variable stores a(n) __________. memory address Most of the programming languages used today are __________. object-oriented A UML diagram does not contain __________. the object names Methods that operate on an object's fields are called __________. instance methods Java allows you to create objects of the __________ class in the same way you would create primitive variables. String Which of the following statements will create a reference, str, to the String "Hello, World"? String str = "Hello, World"; Instance methods do not have the __________ key word in their headers. static The __________ package is automatically imported into all Java programs. java.lang For the following code, which statement is not true? public class Sphere The z field is available to code written outside the Sphere class. For the following code, which statement is not true? The y field is available to code written outside the Circle class. Given the following code, what will be the value of finalAmount when it is displayed? orderNum = orderNumber; There is no value because the object, order, has not been created. Given the following code, what will be the value of finalAmount when it is displayed? orderNum = orderNumber; 522.00 Sets found in the same folderJava Chapter 852 terms sughdic Chapter 963 terms sughdic Java Chapter 1064 terms sughdic Java Chapter 1159 terms sughdic Other sets by this creatorjava24 terms sughdic Implications of Strength and Cogency5 terms sughdic Crit Thinking5 terms sughdic AP Biology 025 - Mechanisms of Timing and Control…16 terms sughdic Verified questions
COMPUTER SCIENCE A prime number is a number that is only evenly divisible by itself and 1. For example, the number 5 is prime because it can only be evenly divided by 1 and 5. The number 6, however, is not prime because it can be divided evenly by 1, 2, 3, and 6. Write a function name isPrime, which takes an integer as an argument and returns true if the argument is a prime number, or false otherwise. Demonstrate the function in a complete program. Verified answer
COMPUTER SCIENCE Write a function that dynamically allocates a block of memory and returns a char pointer to the block. The function should take an integer argument that is the amount of memory to be allocated. If the new operator cannot allocate the memory, the function should return a null pointer. Verified answer COMPUTER SCIENCE Consider the following variable declarations. String s="crunch"; int a=3, b=1; What is printed by the following statements? System.out.print(s+a+b); System.out.printIn(b+a+s); (A) crunch44crunch, (B) crunch413crunch, (C) crunch314crunch, (D) crunch3113crunch, (E) Nothing is printed due to a runtime error. Verified answer COMPUTER SCIENCE Write a method that finds the number of occurrences of a specified character in a string using the following header: public static int count(String str, char a) For example, count("Welcome", 'e') returns 2. Write a test program that prompts the user to enter a string followed by a character and displays the number of occurrences of the character in the string. Verified answer Recommended textbook solutions
Information Technology Project Management: Providing Measurable Organizational Value5th EditionJack T. Marchewka 346 solutions Service Management: Operations, Strategy, and Information Technology7th EditionJames Fitzsimmons, Mona Fitzsimmons 103 solutions
Service Management: Operations, Strategy, and Information Technology7th EditionJames Fitzsimmons, Mona Fitzsimmons 103 solutions
Information Technology Project Management: Providing Measurable Organizational Value5th EditionJack T. Marchewka 346 solutions When a local variable in an instance method has the same name as an instance field the local field variable hides the instance field?Terms in this set (9)
A method may have a local variable with the same name as an instance field. This is called shadowing. The local variable will hide the value of the instance field. Shadowing is discouraged and local variable names should not be the same as instance field names.
When a method means that multiple methods in the same class have the same name but use different types of parameters?Terms in this set (20)
Overloading means multiple methods in the same class: Have the same name, but different parameter lists.
What is an instance method quizlet?What is an instance method? An instance method is a piece of code called on a specific instance of the class. It is called with a receiver object.
Does each instance of a class has its own set of instance fields?Each instance of a class has its own set of instance fields. When you write a constructor for a class, it still has the default constructor that Java automatically provides. A class may not have more than one constructor.
|