public elass Greek int i-l; public int getI() System.out.print ("Super"); return i; public statie void main(String args (1) Greek ga-new Arabik ();. System.out.print (ga.1+" "+ga.getI()); public elans Arabik extends Greek int ie2; public int getI() System.out.print{"Sub"); return i;
Q: public class MyOutput { public static void main(String[] args) { int totalNumbers=6; Double…
A: Given int totalNumber=6 double dblAverage=4.5 Integer yourNumber = new Integer(20);//Wrapper class…
Q: Java Questions - (Has 2 Parts). Based on each code, which answer out of the choices "A,B,C,D,E" is…
A: Both of these questions from the inheritance part of the java. The second question is giving the…
Q: public class P1 { public static void main (String args[]) { int[] numbers = {2,4,10,11,14,28}; int…
A: Here in this question we have given a Java code segment and we have asked to find the output of this…
Q: import java.util.Scanner; public class Application { public static void main(String[] args) { int…
A: Give a Java program All the errors are discussed below.
Q: public class Test { public static void main(String[] args) { int arr[] = {1,2,3,4,5}; int count = 0;…
A: The program is to double the even elements in an array.
Q: Finish the Java program: Code: import java.awt.Point; import java.util.Random; class Main {…
A: A point represent a set of coordinates in two dimension space in form of (x,y). In function…
Q: public class DebugThree2 { public static void main(String args[]) int a = 2, b = 5, c = 10; add(a,…
A: Many syntax and logical errors may disturb our program and prevent us from achieving our output.…
Q: JAVA public interface Interf1 { public void repeat(String s1); } Implement the above…
A: Program is written in java.Please check the source code and output in the following steps.
Q: The String class is provided in the Java library.Provide your own implementation for the following…
A: Below is the required Java code to implement the given class and methods: - Explanation: - Defining…
Q: What does the following code print out? class Main { public static void main (String[] args) { int…
A: In this question, we have given a java code. We have to find the output of the code. We will run the…
Q: class MidtermExam{ private int hour; private String exam; private boolean isResit; public…
A: Programs are the set of lines of code that is used to provide instructions to the computer. The…
Q: public class Poetry extends Consolel { public void run() { String haiku = readline("")
A: GIVEN: Write a java program.
Q: java programming There are three System.out.println() calls in the following code. Find the output…
A: There are three System.out.println() calls in the following code are as follows:
Q: public static void main (String [] args) { first: for( int i = 1; i < 5; i++) { second: for(int j =…
A: Flow chart: The flow chart shows the steps as boxes of different types and their order when the…
Q: Q27 for java programing: public static void main(String[] args) { Dog[] dogs = { new…
A: Find the required answer with explanation given as below :
Q: import java.util.*; public class Car implements Comparable { private int m_inventory; //…
A: import java.util.*; class Car implements Comparable<Car> { private int m_inventory; //…
Q: public class Con{ public static void main(String[] args) { int[] ar=(2,5,7,9}; int i-2; final int…
A: Ouput of the java code public class Con{public static void main(String[] args){int[]…
Q: public class output{ public static int check (int a, int b, int c) { if(a==0) return (b); else if…
A: Given:
Q: Whats the output to this? public static void main(String[] args) { twinInt s =…
A: According to the question below the Solution:
Q: Ex. If the input is: 4 plates 100 spoons 200 cups 150 forks 200 the output is: 200 forks…
A: Actually, the code has given beneath:
Q: Identify the user-defined method based on the program given below. public class Mark int mark1,…
A: The answer is as follows:-
Q: import java.util.Scanner; // import library for scanner class public class weatherInput public…
A: - We need to highlight the correct code in the image provided.
Q: DayTester.java 1 public class DayTester 2 ( public static void main(String() args) 34…
A: Updated Java code for given question import java.util.*; public class DayTester{ public static void…
Q: Write java program for the following class diagram . The Instructions: 1. This java program is for…
A: We will write java code to solve the given problem.
Q: public class MathF{ public static void main(String[] args) { char[] grade=new char[4]; grade[1]='B';…
A: Provided the output of the above code in the next step with a screenshot.
Q: public class Test { public static void main(String[] args) { int[][] array ={{ 8, 9, 10, 11 }, { 4,…
A: Explanation and logic Here we have two dimensional array which can be represent like this(In matrix…
Q: public class My { public static void main(String [] args) { printAll(args); } public static void…
A: Consider the given code:
Q: package Exam; public class Test1 { private static int index = 0; public int x; Test1(){ index ++; }…
A: Introduction: Encapsulation is defined as the wrapping up of data under a single unit. It is the…
Q: public class Test1 { private static int index = 0; public int x; Test1(){ index ++; } public static…
A: Encapsulation is an object oriented programming concept which is to provide more security for the…
Q: Write code in Java: - Code must be recursive. import java.util.*; import java.lang.*;…
A: Given: Write code in Java: - Code must be recursive. import java.util.*; import java.lang.*;…
Q: public class Main5 public static void main(String] args) { int a = 5; int b = 6, float c = alb,…
A: The answer is as follows:-
Q: Task #1 Tracing Recursive Methods 1. Copy the file Recursion.java (see Code Listing 16.1) from the…
A: All Tasks are solved below in Java Programming Language:
Q: public class Test { public static void main(String args[]) int x = 5; int y = 9;…
A: int x = 5; int y = 9; System.out.println(" " + ++y) // output "10" because it is pre…
Q: public class Main { public int a; public long b; public void test(long b) { System.out.println("long…
A: In Java, int takes values from -2,147,483,648 to 2,147,483,647
Q: Convert below code in C++ class Arrival { String flightId,location,arrivalTime; int…
A: The facts need to convert the given code into C++ programming language are listed below: C++…
Q: private int age = 19; public Student () { age = 18; } } public class Test { public static void main…
A: Here we have a class Student which has a data member age and a constructor inside it.
Q: public class DebugBox { private int width; private int length; private int height;…
A: 1) In the parameterize constructor use int datatype before hight while decleration. 2) In the…
Q: 1 class Metov{ 2- void sum(int i,int j){ 3 System.out.printin(i); } 4 void sum(String c,String d){ 5…
A: I have given an answer in step 2.
Q: 1 public class MathF( public static void main(String[] args) 3 { char[] grade-new char[4]; 4…
A: Answer:
Q: code is recursive.
A: Code screenshot
Q: Write the printItem() method for the base class. in Java Sample output for below program: Last…
A: // ===== Code from file ItemInventory.java =====import java.util.ArrayList; public class…
Q: public class main { public static void main(String [] args) { Dog dog1=new…
A: Program: public class main { public static void main(String [] args) { Dog dog1=new…
Q: class Metov{ void sum(int i, int j){ System.out.println(i); } void sum(String c,String d){…
A: when the parameters are Strings, they got added which means appended and result is printed when the…
Q: import java.util.* ; public class MaxFinder { public static void main(String[] args) {…
A: Given: import java.util.* ; public class MaxFinder { public static void main(String[] args)…
Q: public class Test { private int t; public static void main(String] args) { int x;…
A: Please give positive ratings for my efforts. Thanks. ANSWER Here, in the above program, t is…
Q: public class A { private int var1; public int f1() {...} public int f1(int n1) {...} public int…
A: public class A{private int var1;public int f1() {...}public int f1(int n1) {...}public int f2(int…
Q: package Exam; public class Test1 { private static int index = 0; public int x; Test1(){ index ++; }…
A: In the above program the parent class name should not be public parent class and child class have…
Q: public class Student { public static void main(String[] args) { String address = "Delhi, India";…
A: There is no error in the program. Given address="Delhi, India"
Java
Trending now
This is a popular solution!
Step by step
Solved in 2 steps with 1 images
- JAva Implement a class Robot that simulates a robot wandering on an infinite plane. The robot is locatedat a point with integer coordinates and faces north, south, east, or west. Supply methods:public void turnLeft()public void turnRight()public void move()public Point getLocation()public String getDirection()The turnLeft and turnRight methods change the direction but not the location. The move method movesthe robot by one unit in the direction it is facing. The getDirection method returns a string “N”, “S”,“E”, “W”. For the new object, the initial location and facing should be specified. For the initial facing, 0means north, 1 means east, 2 means south, and 3 means west.A tester class, RobotTester, has been provided as follows to help you how to implement the Robot class.Therefore, implement the Robot class such that the following RobotTester class can be executed withoutany changes.import java.awt.Point;/**A class to test the Robot class.*/public class RobotTester{/**Tests the…JAVA Implement the equals method of the Arrow class. Two arrows are equal when they have the same starting point and direction. public class Arrow{ private Point start; private String direction; /** Constructs an arrow. @param x the x-position @param y the y-position @param direction a compass direction N E S W NE NW SE SW */ public Arrow(int x, int y, String direction) { start = new Point(); start.move(x, y); this.direction = direction; } /** Checks whether this arrow is equal to another. @param otherObject another arrow @return true if this arrow and otherObject have the same position and direction. */ public boolean equals(Object otherObject) { /* code goes here */ }}Consider the following code in Java 8:public interface Runnable{void run() ;}public final class Caller {public static void call (String before, String after, Runnable r) (System.out.println(before);r. run() ;System.out.println(after);} }public class MyClass{public static void main(String args[]) (Caller.call("BEFORE", "AFTER",); } }Complete the blark line with some code so that the program prints the folowing to the output: BEFOREHi there!AFTER
- JAVA A Matryoshka, or Russian nesting doll is either solid or hollow. If it is hollow, it contains another doll (which can also be hollow or solid). Given the supplied Doll class, implement a recursive method named show that returns a String representing the chain for dolls, for example Natasha contains Tanya contains Peter public class Doll{ private String name; private Doll dollInside; /** * Constructs a hollow doll with the doll it contains. */ public Doll(String theName, Doll theDoll) { name = theName; dollInside = theDoll; } /** * Constucts a solid doll. */ public Doll(String theName) { name = theName; dollInside = null; } public boolean isSolid() { return dollInside == null; } public String getName() { return name; } public Doll getDollInside() { return dollInside; }} public class DollViewer{ public static String show(Doll d) { /* code goes here */ } public static void main (String [] args) { Doll dolls1 =…Java 1. Class Human: a. Fields: age (int), weight (double), height (double) b. Methods: getAge, getWeight, getHeight 2. Class Student: a. Fields: major (String), gpa (double), creditHours (int) b. Methods: getMajor: returns major, getGpa: returns gpa, getYear: returns freshman, sophomore, junior or senior as determined by earned credit hours: Freshman: Less than 32 credit hours Sophomore: At least 32 credit hours but less than 64 credit hours Junior: At least credit hours SH but less than 96 credit hours Senior: At least 96 credit hours 3.Class Doctor: a. Fields: years (int), Speciality (String) b.Methods: getYears: returns years, getSpecialty: returns speciality, getSalary: calculates salary. The base salary is 40,000 for the 1st year and for each additional year gets 5000 more. So, in second year the doctor gets 45,000, in third year he gets 50,000 and so on. mammal class given* //In Mammal.java Public interface Mammal { public double hairColor(); } 4. Write…Public classTestMain { public static void main(String [ ] args) { Car myCar1, myCar2; Electric Car myElec1, myElec2; myCar1 = new Car( ); myCar2 = new Car("Ford", 1200, "Green"); myElec1 = new ElectricCar( ); myElec2 = new ElectricCar(15); } }
- Given the following class. (JAVA) public class FamilyMember { public String drink( ) {return “cup”;} public String eat( ) {return “fork”;} } Write a Baby class that is derived from the FamilyMember class. The Baby class has an instance variable for the age, a default constructor, and a constructor that accepts an integer. Include any other necessary methods. If a baby is older than 3 years, print that “it eats with its fork”; otherwise, “it eats with its hands”.**Students.java code** // A Java program to demonstrate use of Comparableimport java.util.*; // A class 'Student' that implements Comparableclass Student implements Comparable<Student>{ private String FirstName; private String LastName; private int StudentID; // Used to sort movies by year public int compareTo(Student a) { return this.StudentID - a.StudentID; } // Constructor public Student(String fm, String ls, int id) { this.FirstName = fm; this.LastName = ls; this.StudentID = id; } // Getter methods for accessing private data public String getFirstName() { return FirstName; } public String getLastName() { return LastName; } public int getStudentID() { return StudentID; }} // Driver classclass Students{ public static void main(String[] args) { ArrayList<Student> list = new ArrayList<Student>(); list.add(new Student("Amir", "Alao", 123456)); list.add(new…in java language... Draw the UML diagram of the following class: public class Employee { String name; double salary; public Employee() { } public double getSalary() { return this.salary; } public String getName() { return this.name; } }
- (Java) 7.2 Code: Look at the following Person.java class code: class Person{public String name;public int age;public String gender;public void greeting() {System.out.println( "Hi, my name is " + name + "!");}public void greeting(String otherName){System.out.println("Hi, " + otherName + "!");}public void printPerson () {System.out.println("Name: "+name);System.out.println("Age: "+age);System.out.println("Gender: "+gender);System.out.println();}} Remove the printPerson method from this class. Instead, write a toString() method that can be used to display the Student Object in the following manner: Name: <The Name> Age: <The Age> Gender: <The Gender> Note the use of the <> above. Do not add these <> to your String. Instead, these <> are commonly used to mean a value will be filled in later. Don't forget the @Override tag in front of the toString() method image source Using the below starter code and the toString method, we will…Solve below java problem please. You are given a list of Employee objects and you need to implement a method that returns the top n highest-paid employees. class Employee { private String name; private double salary; public Employee(String name, double salary) { this.name = name; this.salary = salary; } public String getName() { return name; } public double getSalary() { return salary; } }Please help debug this: Debugging Exercise 4-3, Farrell, Joyce, Java Programming, 9th edition, Cengage Learning public class DebugBox { private int width; private int length; private int height; private FixDebugBox() { length = 1; width = 1; height = 1; } public DebugBox(int width, int length, int height) { width = width; length = length; height = height; } public void showData() { System.out.println("Width: " + width + " Length: " + length + " Height: " + height); } public double getVolume() { double vol = length - width - height; return vol; } }