Java Programming
9th Edition
ISBN: 9780357238530
Author: Joyce Farrell
Publisher: Cengage Limited
expand_more
expand_more
format_list_bulleted
Expert Solution & Answer
Chapter 3, Problem 1RQ
Program Description Answer
In Java all the methods should include all the given options except “a call to another method”.
Hence, the correct answer is option “A”.
Expert Solution & Answer
Explanation of Solution
Method:
A collection of statements which are formed together to perform an operation is called as method.
Declaration of a method:
Method declaration gives the description of what the method should perform; Method declaration holds the modifier, return type, name of the method, the list of parameters and the body of the method.
Syntax for defining a method:
modifier return_type methodName(list of parameters)
{
//body
}
Example:
public int findArea(int x, int y)
{
//body
}
The above statement shows the declaration of the method; here,
- public – modifiers
- int – return type
- findArea – name of the method
- x, y – formal parameters
- int x, int y – list of parameters
- Body is the part of the method that contains the statements and the operations to be performed.
Braces:
- Braces usually enclose the number of statements.
- In a function, the numbers of statements are enclosed within the braces.
- The opening of the function contains the open braces “{”.
- The ending of the function contains the close braces “}”.
Want to see more full solutions like this?
Subscribe now to access step-by-step solutions to millions of textbook problems written by subject matter experts!
Students have asked these similar questions
______________ is an example of encapsulation in java.
a.
Data type
b.
Java variable
c.
Java class
d.
Java method
Course Title: Modern Programming Language
Please Java Language Code
Question :
Create a Java Project With Your name as “MJibranAKramProjectQNo1”, add a class to this Project, Class name should be MJibranAkram with 18Arid2891 as “MJibranAkram18Arid2891”
(a) Add a Method to Accept names and marks of n students from user, enter the value of n from User(b) Ensure that valid data is entered. If user enters an invalid data, then appropriate message should be displayed using Message Dialog Box e.g. ‘Name cannot be a number’ or ‘Marks must be an integer value’
(c) Add another Method, to Display this data in descending order according to marks such that name of student having maximum marks should come at the top and the name of student having minimum marks should come at the bottom.
Q1: User Checker
Build a java program that checks on a user who tries to change
current password by asking some questions that user saved their
answers while creating the account as shown below. The
questions below use 5 different String class methods as follows:
• What is your username?
o Check if it's the same name saved regardless of
capital/small letters
• What is your password?
o Check if it is written exactly the same as saved value
• What is your favorite city?
o Check if the city has o letter in middle
• What is your brother age?
o Compare the brother age to 20
• What is your luck number?
o Check if the numeric value is > or < 0
Note: customize the answers of q1 & 2 as you prefer.
Sample Runs (Success & Fail Scenarios):
.....
Chapter 3 Solutions
Java Programming
Ch. 3 - Prob. 1RQCh. 3 - Prob. 2RQCh. 3 - Prob. 3RQCh. 3 - Prob. 4RQCh. 3 - Prob. 5RQCh. 3 - Prob. 6RQCh. 3 - Prob. 7RQCh. 3 - Prob. 8RQCh. 3 - Prob. 9RQCh. 3 - Prob. 10RQ
Ch. 3 - Prob. 11RQCh. 3 - Prob. 12RQCh. 3 - Prob. 13RQCh. 3 - Prob. 14RQCh. 3 - Prob. 15RQCh. 3 - Prob. 16RQCh. 3 - Prob. 17RQCh. 3 - Prob. 18RQCh. 3 - Prob. 19RQCh. 3 - Prob. 20RQCh. 3 - Prob. 1PECh. 3 - Prob. 2PECh. 3 - Prob. 3PECh. 3 - Prob. 4PECh. 3 - Prob. 5PECh. 3 - Prob. 6PECh. 3 - Prob. 7PECh. 3 - Prob. 8PECh. 3 - Prob. 9PECh. 3 - Prob. 10PECh. 3 - Prob. 11PECh. 3 - Prob. 12PECh. 3 - Prob. 13PECh. 3 - Prob. 1GZCh. 3 - Prob. 2GZCh. 3 - Prob. 1CP
Knowledge Booster
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
- In Java, polymorphism refers to the fact that you can have __________ a. multiple class with the same name b. multiple methods with the different name in the same class c. multiple methods with the same name in the same class d. multiple methods with the same name in the different classarrow_forward250. __________ represents a particular instance of a class. a. module b. block c. object d. tokenarrow_forwardNeed a java code Create a class called SingleItem This class represents a bag that can hold any single type of object (decided at bag-creation time), and only one item of that type at a time. You may have a zero-parameter constructor if you want one, but you must have the following three features: Add a method called (addItem()) which returns whether or not it was successfully added Add a method which removes an item from the bag and returns it (deleteAnItem()), return null if there is no item Add a method to check if an item is in the bag (hasAnIteminTheBag()) which returns true or falsearrow_forward
- Python Class and Objects 1. Create a class named "Account" and “Bank” 2. The class “Account” should have a parameter of id - integer type name - string type balance - float type # (Optional) You may add more parameters for your convenience 3. Create a method for “Account” class: checkBalance(self) - this will show the Account's remaining balance or money withdraw(self, amount) - this will withdraw an amount from the Account deposit(self, amount) - this will deposit an amount from the Account # (Optional) You may add more methods like sendMoney() etc.arrow_forwardIn java an interface with no fields or methods is known as a ______. A. Runnable Interface B. Marker Interface C. Abstract Interface D. CharSequence Interfacearrow_forwardProblem Description and Given Info For this assignment you are given the following Java source code files: IStack.java (This file is complete – make no changes to this file) MyStack.java (You must complete this file) Main.java (You may use this file to write code to test your MyStack) You must complete the public class named MyStack.java with fields and methods as defined below. Your MyStack.java will implement the IStack interface that is provided in the IStack.java file. You must implement your MyStack class as either a linked list or an array list (refer to your MyArrayList and MyLinkedList work). Your MyStack must not be arbitrarily limited to any fixed size at run-time. UML UML CLass Diagram: MyStack Structure of the Fields While there are no required fields for your MyStack class, you will need to decide what fields to implement. This decision will be largely based on your choice to implement this MyStack as either an array list or a linked list. Structure of the Methods As…arrow_forward
- PLZ help with the following: IN JAVA Any change to graphics being displayed on the screen requires a call to the method ____________ to update the graphics. paint repaint update all of the abovearrow_forwardIn Java create the following: Design a Ship class that the following members: A field for the name of the ship (a string) A field for the year that the ship was built (a string) A constructor and appropriate accessors and mutators A toString method that displays the ship’s name and the year it was built Design a CruiseShip class that extends the Ship class. The CruiseShip class should have the following members: A field for the maximum number of passengers (an int) A constructor and appropriate accessors and mutators A toString method that overrides the toString method in the base class The CruiseShip class’s toString method should display only the ship’s name and the maximum number of passengers Design a CargoShip class that extends the Ship class. The CargoShip class should have the following members: A field for the cargo capacity in tonnage (an int) A constructor and appropriate accessors and mutators A toString method that overrides the toString method in the base class…arrow_forwardUsing oop in java Create a class “Main” having main method to perform following tasks. Create two objects of Subject class having value “Math, 99.9” and “Physics, 98.9” respectively. Display the values of both objects Change the value of object from 99.9 to 89.9 Compare both objects and display the values of the subject which have lowest score.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
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
Files & File Systems: Crash Course Computer Science #20; Author: CrashCourse;https://www.youtube.com/watch?v=KN8YgJnShPM;License: Standard YouTube License, CC-BY
UNIX Programming (Part - 10) The File System (Directories and Files Names); Author: ITUTEES;https://www.youtube.com/watch?v=K35faWBhzrw;License: Standard Youtube License