Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

PLEASE COMPLETE ALL PARTS IN JAVA PLEASE COMPLETE ALL PARTS IN JAVA PLEASE COMPLETE ALL PARTS IN JAVA PLEASE COMPLETE ALL PARTS IN JAVA PART

PLEASE COMPLETE ALL PARTS IN JAVA

PLEASE COMPLETE ALL PARTS IN JAVA

PLEASE COMPLETE ALL PARTS IN JAVA

PLEASE COMPLETE ALL PARTS IN JAVA

PART 1

image text in transcribed

PART 2

image text in transcribed

PART 3

image text in transcribedimage text in transcribed

PART 4

image text in transcribed

PLEASE COMPLETE ALL PARTS IN JAVA

PLEASE COMPLETE ALL PARTS IN JAVA

PLEASE COMPLETE ALL PARTS IN JAVA

PLEASE COMPLETE ALL PARTS IN JAVA

PLEASE COMPLETE ALL PARTS IN JAVA

PLEASE COMPLETE ALL PARTS IN JAVA

PLEASE COMPLETE ALL PARTS IN JAVA

PLEASE COMPLETE ALL PARTS IN JAVA

TASK: For each of the following Java entities (Class, Abstract Class, and Interface), check all boxes corresponding to true statements about the entity. Tick the right boxes Statement Abstract Class Interface Can be instantiated Can be a variable type Can extend a class Can implement an interface A single class can inherit from multiple of this Can contain non-static method implementations (ignore "default" in interfaces) Can contain method signatures without implementation) We have created a Car class with the following methods (we're intentionally hiding implementation details from you): class Car { public String getMake(); // get the car's make public String getModel(); // get the car's model public String getNoise(); // returns a String of the noise the car makes TASK: Create a class called MyProgram with a main method that does the following tasks: 1. Create a new Car object 2. Print its make 3. Print its model 4. Print the noise it makes We have written the skeleton of a class called Node that has an int instance variable value and a Node instance variable next, where next can be null. TASK: Override the toString method such that, for some Node node, it returns (node.value) ->(node.next.value) -> (node.next.next.value) ->.... EXAMPLE: If we run the following code: Node node = new Node(1) : node.setNext(new Node (2)); node.getNext().setNext(new Node (3)); System.out.println(node); We should print the following: (1)->(2)->(3) HINT: Just like any other method, you can define the toString method recursively! Sample Input: 1 2 3 Sample Output: (1)->(2)->(3) 1 class Node { // instance variables private int value; private Node next; // constructor public Node(int value) { this.value = value; // get the 'next' variable public Node getNext() { return this.next; // set the 'next' variable public void setNext(Node next) { this.next = next; // return a representative String public String toString() { // YOUR CODE HERE } 24 TASK: Create a class called CharGrid that has the following properties: It should have one private instance variable of type char[][] called grid It should have a public constructor that has two int parameters numRows and numCols, which should set the grid instance variable to a char(numRows] (numCols] filled with asterisks (i.e., *) It should have a public constructor that has two int parameters numRows and numCols followed by one char parameter symbol, which should set the grid instance variable to a char[numRows] (numCols] filled with symbol It should override the toString method such that it returns a multi-line String with the symbols in each row on its own line EXAMPLE: If I run the following lines of code: CharGrid myGrid = new CharGrid(3, 10); String myString = my Grid.toString(); Then myString would be the following String: ********** ********** ********** Sample Input: 3 10 Sample Output: ********** ********** **********

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Oracle 10g SQL

Authors: Joan Casteel, Lannes Morris Murphy

1st Edition

141883629X, 9781418836290

More Books

Students also viewed these Databases questions