Java Programming (MindTap Course List)
9th Edition
ISBN: 9781337397070
Author: Joyce Farrell
Publisher: Cengage Learning
expand_more
expand_more
format_list_bulleted
Expert Solution & Answer
Chapter 4, Problem 6RQ
Program Description Answer
With the same name a method variable “overrides” a class variable.
Hence, the correct option is “C”.
Expert Solution & Answer
Trending nowThis is a popular solution!
Students have asked these similar questions
Python
A test of an individual method or even a class in isolation from the rest of the system is called ______ ______.
No hand written and fast answer with explanation
#this is a python program
#topic: OOP
A class has been designed for this question. Solve the questions to get the desired result as shown in the output box.
[You are not allowed to change the code below]
class Wadiya():
def __init__(self):
self.name = 'Aladeen'
self.designation = 'President Prime Minister Admiral General' self.num_of_wife = 100
self.dictator = True
#Write your code for subtask 1, 2, 3 and 4 here
Output:
Part 1:
Name of President: Aladeen
Designation: President Prime Minister Admiral General
Number of wife: 100
Is he/she a dictator: True
Part 2:
Name of President: Donald Trump
Designation: President
Number of wife: 1
Is he/she a dictator: False
Subtask:
1) Create an object named wadiya.
2) Use the object to print the values as shown in part 1 (Also print the sentence Part 1) 3) Use the same object to change and print the values in part 2 (Also print the sentence Part 2)
4) Did changing the instance variable values using the same object,…
Chapter 4 Solutions
Java Programming (MindTap Course List)
Ch. 4 - Prob. 1RQCh. 4 - Prob. 2RQCh. 4 - Prob. 3RQCh. 4 - Prob. 4RQCh. 4 - Prob. 5RQCh. 4 - Prob. 6RQCh. 4 - Prob. 7RQCh. 4 - Prob. 8RQCh. 4 - Prob. 9RQCh. 4 - Prob. 10RQ
Ch. 4 - Prob. 11RQCh. 4 - Prob. 12RQCh. 4 - Prob. 13RQCh. 4 - Prob. 14RQCh. 4 - Prob. 15RQCh. 4 - Prob. 16RQCh. 4 - Prob. 17RQCh. 4 - Prob. 18RQCh. 4 - Prob. 19RQCh. 4 - Prob. 20RQCh. 4 - Prob. 1PECh. 4 - Prob. 2PECh. 4 - Prob. 3PECh. 4 - Prob. 4PECh. 4 - Prob. 5PECh. 4 - Prob. 6PECh. 4 - Prob. 7PECh. 4 - Prob. 8PECh. 4 - Prob. 9PECh. 4 - Prob. 10PECh. 4 - Prob. 11PECh. 4 - Prob. 1GZCh. 4 - Prob. 2GZ
Knowledge Booster
Similar questions
- In Python, to make a variable inside a class private so that functions that are not methods of the class (such as main() ) cannot access it, you must _____________ write the word private then a space before the variable name write the word hide then a space before the variable name start the name of the variable with two underscores do nothing because Python variables declared inside a class are private by defaultarrow_forwardIn C++, members of a class are ______ by default. A. Public B. Private C. Protected D. Static answer choices private public protected staticarrow_forwardThe __________ declares that a derived class is allowed to override a method. a. void keyword b. protected keyword c. base keyword d. virtual keywordarrow_forward
- Please answer these multiple choice questions 1) The new operator: allocates memory is used to create an object of a class associates an object with a variable that names it. All of the above. Answer: 2) A method that performs some action other than returning a value is called a __________ method. null void public private Answer: 3) The body of a method that returns a value must contain at least one _________ statement. void invocation thows return Answer: 4) A variable whose meaning is confined to an object of a class is called: instance variable local variable global variable none of the above Answer: 5) A variable whose meaning is confined to a method definition is called an/a instance variable local variable global variable none of the above Answer: 6) In Java, a block is delimited by: ( ) /* */ “ “ { } Answer: 7) In Java, call-by-value is only used with: objects primitive types this all of the above Answer: 8) The parameter this refers to instance variables local…arrow_forwardCan someone help me with this python question, Thanks!arrow_forwardPythonarrow_forward
- Create a class called Complex for performing arithmetic with complex numbers. Complex numbers have the form realPart + imaginaryPart * i where i is -1 Write a program to test your class. Use floating-point variables to represent the private data of the class. Provide a constructor that enables an object of this class to be initialized when it is declared. Provide a no-argument constructor with default values in case no initializers are provided. Provide public methods that perform the following operations: a) Add two Complex numbers: The real parts are added together and the imaginary parts are added together. b) Subtract two Complex numbers: The real part of the right operand is subtracted from the real part of the left operand, and the imaginary part of the right operand is sub- tracted from the imaginary part of the left operand. c) Print Complex numbers in the form (a, b), where a is the real part and b is the imaginary part.arrow_forwardQuick java class questionarrow_forward2. Write a class named MonthDays. The class's constructor should accept two arguments: • An integer for the month (1 = January, 2= February, etc.). • An integer for the year The class should have a method named getNumberOfDays that returns the number of days in the specified month. The method should use the following criteria to identify leap years: 1. Determine whether the year is divisible by 100. If it is, then it is a leap year if and if only it is divisible by 400. For example, 2000 is a leap year but 2100 is not. 2. If the year is not divisible by 100, then it is a leap year if and if only it is divisible by 4. For example, 2008 is a leap year but 2009 is not. Demonstrate the class in a program that asks the user to enter the month (letting the user enter an integer in the range of 1 through 12) and the year. The program should then display the number of days in that month. Here is a sample run of the program: Enter a month (1-12): 2 [Enter] Enter a year: 2008 [Enter] 29 daysarrow_forward
- When you make a class method const, it means ____. Multiple answers: Multiple answers are accepted for this question Select one or more answers. a the class can have two overloaded methods with seemingly identical heads: one const and the other not b the method won't be allowed to change the data of any class object c any time methods are called using a constant object, the const version is used — or a compile-time error results if no const version exists d the calling object must be a constant object e the calling object will be treated as a constant object during the callarrow_forward7) In Java, call-by-value is only used with: objects primitive types this all of the above Answer: 8) The parameter this refers to instance variables local variables global variables the calling object Answer: Pls answer these mcq's 9) When the parameters in a method have the same as instance variables you can differentiate them by using the _____ parameter. String hidden default this Answer:arrow_forwardsolve in python Street ClassStep 1:• Create a class to store information about a street:• Instance variables should include:• the street name• the length of the street (in km)• the number of cars that travel the street per day• the condition of the street (“poor”, “fair”, or “good”).• Write a constructor (__init__), that takes four arguments corresponding tothe instance variables and creates one Street instance. Street ClassStep 2:• Add additional methods:• __str__• Should return a string with the Street information neatly-formatted, as in:Elm is 4.10 km long, sees 3000 cars per day, and is in poor condition.• compare:• This method should compare one Street to another, with the Street the method is calledon being compared to a second Street passed to a parameter.• Return True or False, indicating whether the first street needs repairs more urgently thanthe second.• Streets in “poor” condition need repairs more urgently than streets in “fair” condition, whichneed repairs more…arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- EBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENTMicrosoft Visual C#Computer ScienceISBN:9781337102100Author:Joyce, Farrell.Publisher:Cengage Learning,EBK JAVA PROGRAMMINGComputer ScienceISBN:9781305480537Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENT
- Programming Logic & Design ComprehensiveComputer ScienceISBN:9781337669405Author:FARRELLPublisher:Cengage
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
Microsoft Visual C#
Computer Science
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Cengage Learning,
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781305480537
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
Programming Logic & Design Comprehensive
Computer Science
ISBN:9781337669405
Author:FARRELL
Publisher:Cengage