Suppose that you have the following declaration. Cylinder cyl = new Cylinder(1.5, 10); Which of the following sets of statements are valid in Java? (i) cyl.set(2.5, 10); System.out.println(cyl); System.out.println(cyl.volume()); System.out.println(cyl.syfaceArea()); (i) cyl.set(2.5, 10); cyl.print(); cyl.volume.print(); cyl.syrfaceArea.print(); a. Only (i) b. Only (ii) c. Both d. None of these.
Q: Given the class Pet below, write a client program to read data for five pets and display the…
A: The required Java code is: /**Class for basic pet data: name, age, and weight. */import…
Q: IN JAVA Given an array of numbers, return whether it is possible to make the number 7 by adding any…
A: Algorithm - Take one string as input. Now use the below logic for(int i=0;i<r.length;i++){…
Q: Using Java, write the following code for a program to convert Hexadecimal to Decimal. Write a class…
A: import java.util.Scanner; class Hex{ public static int parseInt(String hex) { int…
Q: Write a method in Java called processName that accepts a Scanner for the console as a parameter and…
A: JAVA CODE: //import the Scanner class...import java.util.Scanner; public class Main{ //define the…
Q: howMany lineLength Output 12 [1][2][3][4] 4 10 [1][2][3] [4] 3 [1] [2] [3] Error! lineLength must at…
A: see the below code In this code user enter how many number you want to print next, user enter…
Q: Write a complete Java program in a class named TwoRockets that generates the following output. Use…
A: Java program for the given problem is: public class TwoRockets { public static void main(String[]…
Q: Write a complete Java program in a class named EggStop that generates the following output. Use…
A: A class is a group of objects which have common properties. It is a template or blueprint from which…
Q: OR JAVA Write a method that takes a string as a parameter, and returns the inverse of the string.…
A: import java.util.*;class ReverseString{ public static void main(String args[]) { String…
Q: Someone please help and teach me , based on the java source code given , how can i add a feature of…
A: To add a virtual payment gateway you have to create a web/User interface (UI) first where all the…
Q: IN JAVA Given an array of numbers, return whether it is possible to make the number 7 by adding any…
A: In this problem, we need to design the Java program that will be able to solve the mentioned…
Q: How to answer the following question in java The equals method for Circle objects defined in the…
A: QUESTION 1 : The equals method for Circle objects defined in the text determines equality of two…
Q: (Java) 2. What will the following display to the console? Work out the solution by hand first (i.e.…
A: As per the requirement given program is executed. And paper work also done. Algorithm: Step 1:…
Q: Please answer Number 4 and 5 as they are associated altogether 4. Explain Java variable scope in…
A: Java variables are named location that stores data in memory. Scope of a variable defines access…
Q: IN JAVA Given an array of numbers, return whether it is possible to make the number 7 by adding any…
A: class LuckySeven { boolean find3Numbers(int A[], int arr_size, int sum) { int l, r; for (int i =…
Q: Consider the method headings: void funcOne(int [ ] alpha, int size)…
A:
Q: Write a class that has three overloaded static methods for calculating the areas of the following…
A: Please find the answer below
Q: Write a method to print all of the strings that contain the substring "ware" in the following array:…
A: public class Main{ //method to print all of the strings that contain substring "ware" //in the…
Q: Write code for a Java class Rectangle with the following fields and methods: Rectangle - width :…
A: /** File: Rectangle.java** Summary of file:* * This file contains the Rectangle class* with all the…
Q: In Java, isn't a String an object? When I pass a String from method A to void method B as a…
A: Hey there, I am writing the required solution based on the above given question. Please do find the…
Q: How many objects of type Car are created? Car mustang = new Car(); Car prius; int miles; Truck…
A: The correct solution along with the intern is given below.
Q: 1. Consider the following lines of coding written in Java, Your teacher went through similar type of…
A: Since you are asking multiple questions, we are doing first question only, if you want solution of…
Q: Write a java program and also attach SS of output. Why do we need encapsulation? What happens if…
A: Encapsulation is the process of wrapping the data and code together as a single unit. Because of…
Q: I have to write a java program that will allow me to insert Ravens 13 3 and output "Congratulations,…
A: For class team we need to do following things: // TODO: Declare private fields - teamName,…
Q: he required attributes are:Movie CD: Movie Title, Year of Release, Lead Actor Name, CD price and CD…
A: onsider the case of a shop that sells CDs in cash. The CDs are of three types: Movie CDs, Software…
Q: Which of the following statements are true for Java? (You can select as many answers as you want O…
A: Interface doesnt hold by itself instance variables of its own as by default inside interface…
Q: I NEED JAVASCIPT SOLUTION PLEASE Task An ATM only has 100, 50 and 20 dollar bills (USD)…
A: Step-1: StartStep-2: Declare a variable amount and take input from userStep-3: Call function…
Q: Write a java code where the usser can play a game of rock paper sciscors 3 times agaist a computer…
A: CODE:- import java.util.Random; /* This class ecapsulates the state and logic required to play the…
Q: Define a class named Rectangle. A Rectangle object stores an (x, y) coordinate of its top/left…
A: Code : public class Rectangle { int x; int y; int width; int height; public Rectangle(int x, int…
Q: How many items are returned from printValues()? public static void printValues(int a, int b){
A: Solution :
Q: IN JAVA Given an array of numbers, return whether it is possible to make the number 7 by adding any…
A: Algorithm - Take one string as input. Now use the below logic for(int i=0;i<r.length;i++){…
Q: The following Java code is poorly structured. Rewrite it so that it has a better structure and…
A: Please refer to the following steps for the complete solution to the problem above.
Q: 3. A JavaBean has the following component: private boolean test; Which two pairs of method…
A: your question is about Javabean. let's solve the question
Q: In the main method add the following declarations: int[ ] arr1 = {1,2,3,4,5,6,7,8,9,10}; int[ ]…
A: int[ ] arr1 = {1,2,3,4,5,6,7,8,9,10}; //initializes arr1 int[ ] arr2 =…
Q: Write Java program to do the following: a filled JList with 10 books and their corresponding prices…
A: Code import java.awt.*;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;…
Q: Write the appropriate method headings using the provided method names for ead of the following…
A: AREA of Circle Import the scanner class Create a class Area with data member area and member…
Q: Write a Java application that calculates the sum of a series of integers that are passed to method…
A: As given, I need to write a java program with sum() method which takes variable-length arguments and…
Q: IN JAVA Given an array of numbers, return whether it is possible to make the number 7 by adding any…
A: In this problem, we need to design the Java program that will be able to solve the mentioned…
Q: Show the derivation of the asymptotic run time, O(n), for each of the following methods. You may…
A: The question is to find the asymptotic time complexity of the given java code.
Q: Write a program in java called LuckySevens.java that takes an int as a command-line argument and…
A: Program Approach – Declare the class named LuckySevens Define the main method. Declare the…
Q: Write a Java method called isVowel that checks the received letter is vowel (returns true) or not…
A: Algorithm to check whether input character is vowel or not Input the character value. Check whether…
Q: In Java 1. Suppose you have a class Circle that represents circles which all have centers at the…
A: A total ordering for a set is a set which satisfies all the four conditions, the first three…
Q: Write a program called Deleted_position.java that has a method with one int array as a parameter,…
A: I give the code in Java along with output and code screenshot
Q: Write a java program that will create a Deck object and shuffle the deck. Then, you will draw ten…
A: Please find the answer below :
Q: How to create a class in java that contains get and set methods for the double variables…
A: A Java program for the given criteria is as follows, File name: “MyRectangle2D.java” //Create a…
Q: Based on the java source code given , how can i add a simple payment system in the code. Please…
A: Errros
Q: Assume w, x, y, and z are distinct boolean variables. In a correctly written truth table for the…
A:
Q: What is the output of the following code? ( Assume each class is defined in a separate java file).…
A: According to the Question below the solution:
Q: Which is true about testing a method with three integer parameters and one integer return value? A.…
A: Solution :
Q: A new deadly virus has infected large population of a planet. A brilliant scientist has discovered a…
A: So as per the question logic for code should be, vaccine count of midichlorains will be higher than…
Q: 8. How many methods exist in the following Java program ? Line-1 : public class WHYME{ Line-2 :…
A: Your question is about total number of java method. Let's find the solution of the question.
Suppose that you have the following declaration. Cylinder cyl = new Cylinder(1.5, 10);
Which of the following sets of statements are valid in Java?
(i)
cyl.set(2.5, 10);
System.out.println(cyl);
System.out.println(cyl.volume());
System.out.println(cyl.syfaceArea());
(i)
cyl.set(2.5, 10);
cyl.print();
cyl.volume.print();
cyl.syrfaceArea.print();
a. Only (i)
b. Only (ii)
c. Both
d. None of these.
Trending now
This is a popular solution!
Step by step
Solved in 2 steps
- Course Title: Modern Programming Language Please Java Language Code Question : Design an abstract class GeometricObject. GeometricObject must ensure that its children must implement calcArea() method. Design Rectangle18-ARID-2891 and CircleM.JibranAkram Classes as children of GeometricObject class with overridden toString() method to return “Rectangle with w Width and h Height is drawn” OR “Circle with r Radius is drawn”. The attributes of Rectangle are length, width. The attribute of Circle is radius Hint: Area of circle=πr2 , Area of rectangle= width*lengthConsider the following class definition: class circle { public: void print() const; void setRadius(double); void setCenter(double, double); void getCenter(double&, double&); double getRadius(); double area(); circle(); circle(double, double, double); double, double); private: double xCoordinate; double yCoordinate; double radius; } class cylinder: public circle { public: void print() const; void setHeight(double); double getHeight(); double volume(); double area(); cylinder(); cylinder(double, double, private: double height; } Suppose that you have the declaration: cylinder newCylinder; Write the definitions of the member functions of the classes circle and cylinder. Identify the member functions of the class cylinder that overrides the member functions of the class circleclass Point with instance variables as: xCoordinate(int) and yCoordinate(int). Write public instance methods (getters & setters) for each instance variable. Now, write a class Circle with private instance variables as radius and Pi (value is 3.14). Write public setter, getter for radius, Area method for calculating Area, Draw method for radius. Formula for calculating area=pi*r^2 Formula for calculating radius=Math.sqrt(xCordinate^2+yCordinate^2) Extend a Circle class from Point class such as Class Circle extends Point Write a Default constructor in Circle class that sets radius, xCoordinate&yCoordinate to some default value e.g. -1; Write a Parameterized constructor in Circle class which takes xCoordinate, yCoordinate and radius as a parameter. E.g. Circle (int xCoordinate, int yCoordinate, double radius) { this.xCoordinate= xCoordinate; this.yCoordinate= yCoordinate;…
- UML for the following Code: public class ProductOrder { private int numBook = 0; private int numCD = 0; private int numDVD = 0; public ProductOrder(int numBook, int numCD, int numDVD){ this.numBook = numBook; this.numCD = numCD; this.numDVD = numDVD; } public int getBook(){ return numBook; } public void setBook(int numBook){ this.numBook = numBook; } public int getCD(){ return numCD; } public void setCD(int numCD){ this.numCD = numCD; } public int getDVD(){ return numDVD; } public void setDVD(int numDVD){ this.numDVD = numDVD; } public int getProductTotal(){ return getBook() + getCD() + getDVD(); } }# Coding - Simulate a robot Write a program that simulates the movements of a robot. The robot can have three possible movements: turn right turn left advance The robot is placed on a hypothetical infinite grid, facing a particular direction (north, east, south, or west) at a set of `{x,y}` coordinates,e.g., `{3,8}`, with coordinates increasing to the north and east. Create a Class `Robot` that contains a method `execute` which given a number of instructions will calculate the robot's new position, and the the direction in which it is pointing. ## Example The letter-string "RAALAL" means: Turn right Advance twice Turn left Advance once Turn left yet again Say a robot starts at `{7, 3}` facing north. Running this stream of instructions should leave it at `{9, 4}` facing west. ## Inputs and Outputs The argument of the `execute` is `string` in the format `X Y BEARING COMMANDS`. The method should return a one-liner `string` in the format `X Y BEARING`. In the…Java Object Oriented Programming Create a Shape class that shall have color and filled instance variables of enum Color and boolean type. The filled boolean variable shall show, whether the shape is filled (colored). The enum Color shall be defined within the class having 4 color names (choose any four). Also define getArea and getPerimeter method in Shape class, both shall return 0. Create Rectangle class with length and width attributes and a Circle class with radius attribute, of type double. Properly encapsulate all fields. Circle and Rectangle shall extend Shape class and override getArea and getPerimters methods as per its type and specific formula. In Test class, create an object of Rectangle and Circle, by initializing all attributes in constructor and print both shapes' area and perimters. In Test class, define a static method with following signature, public static void printEachShapeCount(Shape... shapes) As you know, the parent type variable can hold the…
- Java programming lanaguage A. Design and implement the class Circle that contains the double private data field radius and the following member methods: getRadius that returns the radius of Circle setRadius that sets the radius of Circle area that calculates and return the area of a Circle object (area = π*r²). toString that returns the radius of a Circle object as a string. Two constructors; the first one without arguments. The second constructor with one parameter r. It initializes the radius to r. B.Design and implement the class Cylinder that inherits the class Circle and contains one double private data field height and the following member methods: getHeight that returns the height of Cylinder setHeight that sets the height of Cylinder area that calculates and return the area of a Cylinder object (area = 2*π*r²+2*π*r*h). volume that calculates and return the volume of a Cylinder object (volume = π*r²*h). toString that returns the radius and height of a Cylinder object as…Create a RightTriangle class given the following design: RightTriangle variables: base, height methods: 2 constructors, 1 that set default values and another that accepts to parameters. setBase - changes the base. Requires one parameter for base. setHeight - changes the height. Requires one parameter for height. getBase - returns the triangle base. getHeight - returns the triangle height. area - returns the area of the triangle (1/2bh) given the current base and heightThe Robot class models the state and behavior of virtual robots. Each robot corresponds to an object that is an instance of this class. Each robot: properties: Has a modelNumber (int) Has a direction(String): given by the direction attribute that takes one of the values "North", "East", "South" or "West" Has a makeYear (int): the year the robot was made. Methods: Can turn left 90 ° to change direction (if its direction was "North" it becomes "West", if it was "West" it becomes "South", if it was "South" it becomes "North", etc.). with the method without parameter turnLeft () Can display its detail with the method myInfo().
- Java program: The class diagram with four classes Mammal, Human, Student and Doctor is given. The Mammal class is given as well. Write down the remaining classes as described in the class diagram. The fields and methods for each class is given in the attachment. //in Mammel.java Public interface Mammal{ public double hairColor(): } 1. Class Human: Fields: age(int), weight(double), height(double) Methods: getAge, getWeight, getHeight 2. Class Student: Fields: major (String), gpa (double), creditHours (int) methods: getMajor: returns major, getGpa: returns gpa, getYear: returns freshman, sophmore, junior, senior as determined by earned credit hours Freshman : less than 32 credit hours sophmore: at least 32 but less than 64 credit hours junior: at least 64 credit hours but less than 96 credit hours senior: at least 96 credit hours 3.Class Doctor: Fields: years(int), Speciality (String) methods: getYears: returns years, getSpeciality: returns speciality, getSalary: calculates…Class: Square Create a class called "Square", which is inherited from“TwoDimensionShape” class. The "Square" class is used to calculate theArea and the Perimeter of square shapes when their side-length is given, or in contrast,finding the side-length of the square when the Area or the Perimeter of the square is given.The specifications of this class are below. Data Members (Attributes): All are private. sideLength: the sidelight (L) of the square. Methods/Operations/Getters/Setters: Default Constructor: when creating an object this constructor must set the side-length of the square by calling the method setSideLength(). Also, this constructor willcall the findArea() and the findPerimeter() in addition to summaryPrint() to calculateand print all needed information. User-Defined Constructor: when creating an object this constructor shouldfind the side-length of the square by calling the method findSquareSideLength()and pass the Area or the…Classes – Write a class to represent a AlternativeEnergyCar. Select the fields and methods that fit the modeling of an alternative energy car. Make sure to include code for the constructors, set/get methods, a toString() method.