import javax.swing.JOptionPane; public class Sandwich { private string mainIngt; private string breadType; private double price; //Default Constructor: pulbic Sandwich () { mainIngt = ""; breadType = ""; price = 0.0; } %3D
Q: 4. Create an interface Wheel with methods setWheels (int c) and getWheels () and a class Vehicle…
A: Solution: Given,
Q: Design a class named Triangle that extends GeometricObject: import java.util.Scanner; abstract…
A: The Code is below:
Q: Java programming lanaguage A. Design and implement the class Circle that contains the double…
A: Here I have created a class named Circle. Here I have created a variable named radius. Next, I have…
Q: Question : Design an abstract class GeometricObject. GeometricObject must ensure that its children…
A: Program: Programs are generally used to interact with computer systems. The main objective of the…
Q: Explain the answer step-by-step and include verbal explanation. Thank you! Look at the following…
A: The mutator functions are using the local formal argument name same as the class property which is…
Q: (Classes and Objects) Hand-write a complete Java class that can be used to create a Car object as…
A: Instance variable in private scope. Using this pointer within default constructor with no arguments.…
Q: Code: interface Bicycle{ //interface for bicycle void changeGear(int val); //abstract…
A: Solution is given below-
Q: Java Problem. compile and run the code below: /** A class to test the Door class. */ public…
A: Class definition: A class is a user-defined data type that contains the data members and methods.…
Q: (B) Add a class named Square.java • Give it private attributes double side and String color • Make a…
A: Below is the required code in java and sample output:
Q: JAVA CLASS AND OBJECT JAVA JAVA JAVA Write a java program/code of the given problems below:…
A: Due to the honor code, i can solve only 1st bit. Please resubmit the remaining questions. The given…
Q: 1. Create a UML diagram for part of the String class by reading the Java API. Your diagram should…
A: There are lot of static methods and instance methods and few of them are represented in class…
Q: (B) Add a class named Square.java Give it private attributes double side and String color Make a…
A: checkfurther steps for the answer :
Q: at has following methods: sum, multiply, divide , modulus , sin , cos , tan
A: JAVA code Create a Calculator class that has following methods: sum, multiply, divide , modulus ,…
Q: Use java programming language 1.1 Create a Student Object project. Create a Student class and use…
A: Student.java =================== import java.util.Random; public class Student { //declare variables…
Q: For example, 1.Input: ["Once","a","upon","time"], Output: ["Once","a","time","upon"] 2.Input:…
A: According to the information given:- We have to follow the instruction mention to obtain desired…
Q: 1. Create a UML diagram for part of the String class by reading the Java API. Your diagram should…
A: Let the private instance variable be values Let the constructors be default and parameterized which…
Q: Course Title: Modern Programming Language Please Java Language Code Question : Design an abstract…
A: Circle.java public class Circle extends GeometricObject { private double radius; public Circle()…
Q: write a java program This composition example contains classes Date, Employee and EmployeeTest…
A: Given: Class EmployeeTest creates two Date objects to represent an Employee’s birthday and hire…
Q: : Java Class Inheritance with an abstract class Define a class Employee with the following…
A: As per our guidelines we are suppose to answer the first question. Kindly post the remaining…
Q: Java Question - Based on code, which answer out of the choices "A, B, C, D, E" is correct. Question…
A: The answer is given below.
Q: Case Diagram and UML Class Diagram for this java code : (Below the code give some constructive…
A: In this question, I'll be discussing the constructive critiques about UML. Below is the solution.
Q: Look at the following class declarations: class Plant { public virtual void Message() {…
A: OUTPUT: - I'm a tree. It is an example of Method overriding. The object of the Tree class is…
Q: (B) Add a class named Square.java Give it private attributes double side and String color • Make a…
A: Given The answer is given below. Below is the required code in java and sample output:
Q: JAVA WRITE THE OUTPUT OF THE PROGRAM AND WRITE THE UML DIAGRAM OF THESE PROGRAM : A.) public class…
A: In the given program code, we define a class Invoice with private members integer type item_number,…
Q: Create an interface MessageEncoder that has a single abstract method encode(plainText), where…
A: // MessageEncoder.java public interface MessageEncoder { // encode and returns the given plain…
Q: USING ENCAPSULATION IN JAVA. Create a class Car then declare properties that can describe a Car,…
A: According to the question OOPs is one of the great pillars of Java that has used its power and ease…
Q: Select the default constructor signature for a Student class. A. public Student( ) B. public void…
A: Language is one of the most widely used programming language which has been used to create different…
Q: Explain the following Java Inheritance code in details. public class Point extends Object {…
A: Inheritance is the Java feature which allows a class to inherit the protected and public data…
Q: * Constructor for objects of class SimpleBankAccount public SimpleBankAccount (){ balance- 0.0; ac…
A: Given that:
Q: java Prepare an abstract class SpecialColor with one property the color name (String) and two…
A: The three classes will be created as follows: Class SpecialColor This class has one attribute called…
Q: Explain the answer step-by-step . Include verbal explanation. Thank you! 4. Write two…
A: Write two constructors for the below class: the constructor for the class is given below both…
Q: Java A class always has a constructor that does not take any parameters even if there are other…
A: A constructor in Java or a Java constructor is a basic term which is used to define a process which…
Q: Write a Rectangle class. Its constructor should accept length and width as a parameter. It should…
A: Answer has been explained below:-
Q: Java allows extending multiple classes through a single class declaration statement such as: public…
A: Multiple inheritance: A class that inherits the properties from two or more classes is called…
Q: Implement the concept of polymorphism in Java. • Create a class named Person o AabstractgetName()…
A: public abstract class Person{ public String name; //declare instance variable public…
Q: UML for the following Code: public class ProductOrder { private int numBook = 0; private…
A: Answer: We have written UML diagram for given following code
Q: In Java Use inheritance to create the class PassengerPlane. An object of this class includes a…
A: Introduction of the Program: The Java Program uses the concept of inheritance. Here the Airplane…
Q: In java language on netbeans design a console application that will print the game sales for a…
A: Here I have created the class Games that implements the interface iGames. In this class, I have…
Q: Fill in the blanks for the method signature of a Deep Copy constructor for the Plant class. public…
A: Please find the answer below
Q: + constructor() get vacationList() : Array [] addVacation(vacation) : Array [] + toString() : String…
A: Since we are going to use array in this problem so let's understand arrays and take a look at some…
Q: tumLeft and turn Right methods that change the direction of the robot but not the location move…
A: public class Robot{ //declaring instance variables private String name; private int xPos; private…
Q: An encapsulation violation occurs when private information that should not be changed by external…
A: Encapsulation in object-oriented programming usually known as binding the data altogether with the…
Q: WRITE THE OUTPUT OF THE PROGRAM AND WRITE THE UML DIAGRAM OF THE PROGRAM : JAVA
A: Output: Item Number:112Name: BookQuantity: 3Price: 125.98Total Cost: 0.0Item Number:101Name:…
Q: class Employee { String name; double salary; public Employee() { }
A: The class is EMPLOYEE. It has got a constructor of same name. Attributes are: 1. name of type…
Q: // Superclass public abstract class Vehicle { public abstract double getKMPerlitre(); (Other methods…
A: Find the Error //Superclass Public abstract class Vehicle { public abstract double getKMPerLitre(…
Q: Please define two interface Auto and Sprinkler, and three classes Car, Truck and FireTruck. Car and…
A: Code: interface Auto{ public abstract void move(); public abstract void stop(); public…
Q: Design and implement a Java class named Book with two data members: title and price. The class…
A: Class Book contains basic details about book and getter/setter method. Class BookShelf contains an…
do you know why "string" does not highlight while using java?
Trending now
This is a popular solution!
Step by step
Solved in 3 steps
- What is outpout? public class Vehicle { public void drive(){ System.out.println("Driving vehicle"); } public class Plane extends Vehicle { @Override public void drive(){ System.out.println("Flying plane"); } public static void main(String args[]) { Vehicle myVehicle myVehicle.drive(); } } = new Plane(); syntax error Driving vehicle Flying plane Flying plane O Driving vehicleQUESTION 15 public class numClass { private int a; private static int y = 10; public numClass(int newX) {a=newx; } public void set(int newx) { a=newx; y+=a; } public void setY(int newy) { y=newY; } public static int getY() { return y; } }// end of class public class output { public static void main(String[] args) { numClass one = new numClass(10); numClass two = new numClass (2); try{ one. sety(30); two.set(4); if(one.getY()==30) throw new Exception ("30"); one.setY(40); } catch (Exception e) { two.sety (50); } System.out.println(two.getY()); }// end of main } // end of class8. OOPS Theory #6 public class Car { public void horn() { System.out.println("Horn horn"); } } public class Ferrari extends Car { public void horn() { System.out.println("Ferarriiiiii"); } } public static void main(String[] args) { Ferrari ferrari = new Car(); ferrari.horn(); } Pick ONE option Horn horn Ferarriiii Cannot compile Runtime exception Clear Selection 9. OOPS Theory #7 In Java, we can achieve the abstraction by creating the blueprint of an object and only have abstract methods. What do we call this? Pick ONE option Interface Encapsulation Instance Protected Clear Selection
- Question 13 What is outpout? public class Vehicle { public void drive(){ System.out.println("Driving vehicle"); } } public class Plane extends Vehicle { @Override public void drive(){ System.out.println("Flying plane"); } public static void main(String args[]) { Vehicle myVehicle= = new Plane(); myVehicle.drive(); } Driving vehicle syntax error Flying plane Driving vehicle Flying plane }Q 3: Different packages and access modifiers package package_02; public class ClassB { public int x - 1; int y = 2; private int z = public void myMethod () { System.out.print(x); System.out.print(y); System.out.print(z); 3; } package package_01; import package_02.classB; public class ClassA { public static void main(String[] args) { ClassB cb = new ClassB(); cb.myMethod (); } } 3.1- Which statement(s) are true? Choose all that apply. a. This code prints "123" to the output. b. If you remove the "public" modifier from the ClassB, the code writes "123" to the output. c. If you remove the "public" modifier from the method myMethod, the code prints "123" to the output. d. This code does not compile 3.2- What do you expect if you remove the public keyword from the ClassB (public class ClassB{.}}?interface StudentsADT{void admissions();void discharge();void transfers(); }public class Course{String cname;int cno;int credits;public Course(){System.out.println("\nDEFAULT constructor called");}public Course(String c){System.out.println("\noverloaded constructor called");cname=c;}public Course(Course ch){System.out.println("\nCopy constructor called");cname=ch;}void setCourseName(String ch){cname=ch;System.out.println("\n"+cname);}void setSelectionNumber(int cno1){cno=cno1;System.out.println("\n"+cno);}void setNumberOfCredits(int cdit){credits=cdit;System.out.println("\n"+credits);}void setLink(){System.out.println("\nset link");}String getCourseName(){System.out.println("\n"+cname);}int getSelectionNumber(){System.out.println("\n"+cno);}int getNumberOfCredits(){System.out.println("\n"+credits); }void getLink(){System.out.println("\ninside get link");}} public class Students{String sname;int cno;int credits;int maxno;public Students(){System.out.println("\nDEFAULT constructor…
- 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); } }public class LabProgram { public static void main(String args[]) { Course course = new Course(); String first; // first name String last; // last name double gpa; // grade point average first = "Henry"; last = "Cabot"; gpa = 3.5; course.addStudent(new Student(first, last, gpa)); // Add 1st student first = "Brenda"; last = "Stern"; gpa = 2.0; course.addStudent(new Student(first, last, gpa)); // Add 2nd student first = "Jane"; last = "Flynn"; gpa = 3.9; course.addStudent(new Student(first, last, gpa)); // Add 3rd student first = "Lynda"; last = "Robison"; gpa = 3.2; course.addStudent(new Student(first, last, gpa)); // Add 4th student course.printRoster(); } } // Class representing a student public class Student { private String first; // first name private String last; // last name private double gpa; // grade point average…public class Father { public String name; public int age; // customer name Father(){ name=”Hassan”; age=50;} public void display(){ System.out.println(“Name:”+name); System.out.println(“Age:”+age); } } 1. Based on Figure 3, create a class named Child that inherits the Father class. Declare an instance name location (String) for class Child. 2. Define a constructor in class Child and give an appropriate initial values for the instance (name, age, location). 3. Define a method display () in class Child, execute the display ( ) method in superclass using the keyword super. Method display ( ) in class Child should print the information of name, age and location 4. Create other class named Main for the main method and create 2 objects for the 2 classes (Father and Child). Then execute the display ( ) method for Father and Child. Example of the output as in Figure 4: Father's info: Name: Josh Age: 50 Child's info: Name: Christy Age: 20 Location:…
- 7. public class Father { public String name; public int age; // customer name Father(){ name="Hassan"; age=50;} public void display(){ System.out.println("Name:"+name); System.out.println("Age:"+age); }} Figure 3 i. Based on Figure 3, create a class named Child that inherits the Father class. Declare an instance name location (String) for class Child. ii. Define a constructor in class Child and give an appropriate initial values for the instance (name, age, location). Define a method display () in class Child, execute the display () method in superclass using the keyword super. Method display () in class Child should print the information of name, age and location. ii.public class Application { public static void main(String[] args) { Employee empl = new Employee(); empl.firstName = "Ali"; empl.lastName = "Omar"; empl.salary = 20000; Employee emp2 = new Employee(); emp2.firstName = "Mohamed"; emp2.lastName = "Nour"; emp2.salary = 30000; System.out.println("- System.out.printin("- empl.employeeSalary(); System.out.println("- empl.checkEmployeeSalary(emp1.salary, emp2.salary); System.out.printin("- System.out.println("- printEmployee(emp2); System.out.printin("- Employee employeeArr[] = new Employee[2]: employeeArr[0] = empl; employeeArr[1] = emp2; Application a = new Åpplication(); a.printArrayofEmployee(employeeArr); Non static (instance) start to call Static function to print ---------"); "); - Non Static function to print - --"); Non static (instance) start to call same class Static function to print --------); -"); Non Static function to print ----); System.out.println("- System.out.printin("- System.out.printin("Salary : " + Employee.salary);…public class Animal { public void makeNoise() { System.out.println("talk"); }//end method makeNoise }//end class Animal public class Dog extends Animal { public void makeNoise() { System.out.println("Bark"); }/lend method makeNoise }//end class Dog What would the output of the following be? Explain your answer. Animal animal = new Animal(); animal.makeNoise(); Dog dog = new Dog(); dog.makeNoise(); Animal animaldog = new Dog(); animaldog.makeNoise();