Answered step by step
Verified Expert Solution
Question
1 Approved Answer
1) Using your choice of C# or Java (NOT in Pseudocode), write an abstract class Vehicle. The Vehicle class contains at least these two attributes:
1) Using your choice of C# or Java (NOT in Pseudocode), write an abstract class Vehicle. The Vehicle class contains at least these two attributes: id (int type) and model (String type) and an abstract method vehicleDetail0 that will have two arguments for the vehicle id and model. Then write two concrete classes Car and Bus that inherit the Vehicle class and implement the abstract method that displays vehicle id and model. You don't need to include the main) method. uestion 2 (15 points) 2) Using the previous Vehicle, Car and Bus classes, assume that there is a main) method that contains the following expressions. You job is to identify which of the following polymorphic expressions are correct. Write your answers very precisely [All in one word, by alphabetic orderl, something as ollows: ABD or ACE A) Vehicle v1- new Vehicle0 B) Car v2- new Car C) Vehicle v3-new Car 0; D)Bus v4-new Car 0; 3) Using your choice of C# or Java (NOTin PseudoCode), write an interface Vehicle. The Vehicle contains a method vehicleType0. Then write two concrete classes Truck and Train that inherit the IVehicle interface and include the unimplemented vehicleType0 method. You don't need to include the main0 method. But in each of the concrete classes the vehicleType() method MUST be implemented with at least one PRINT statement, with whatever you like to display. Question 4 (3 points) string 4 a) Write the output in either Java or C# perspective of the following string operations, assuming that the PRINTO method is a function that prints to the screen. Please note that there is no difference between "String" and "string" in C#. is a function that prints to the String oop "I like Object-Oriented Programming" PRINT (oop.substring(7, 14); Question 5 (3 points) 4 b) Write the output in either Java or C# perspective ofthe following string operations, assuming that the PRINTO method is a function that prints to the screen. Please note that there is no difference between "String" and "string" in C#. String s "Object Orientation"; s- s+s.length0: PRINT(s); Question 6 (3 points) 4 c) Write the output in either Java or C# perspective of the following string operations, assuming that the PRINTO method is a function that prints to the screen. Please note that there is no difference between "String" and "string" in C#. String river -"Mississippi River"; PRINT(river.substring(0, 6)); 4 d) Write the output in either Java or C# perspective of the following string operations, assuming that the PRINTO method is a function that prints to the screen. Please note that there is no difference between "String" and "string" in C#. PRINT (river.substring(2, river.length0 3); Question 8 (3 points) 4 e) Write the output in either Java or C# perspective of the following string operations, assuming that the PRINTO method is a function that prints to the screen. Please note that there is no difference between "String" and "string" in C# PRINT(river.substring(2)); Question 9 (15 points) 5) Given the Car class below, which of the five (5) statements (A thru J) are correct: Write your answers very precisely [All in one word,by alphabetic order], something as follows: ABCDE or, CDEFJ class Car (int id; static String model; void setID.. static void setModel ) .. public class StaticMain f public static void main(String[] args) f Car c1 = new Car(); A Car.id -F9C1010; B. cl.id 1010 C, model = "Ford"; D. Car.model "Ford" E. c1.model-"Ford" F. Car.setId) G. setId ) H. setModel ) I. cl.setModel ) J. Car.setModel(O Question 10 (15 points) 6) Of the follow statements (A thru I), chose the five (5) correct ones Write your answers very precisely [All in one word, by alphabetic order ], something as follows: ABCDE or, CDEF A. Abstract classes can be instantiated to create objects, whereas Interfaces cannot. 8. All methods in an Abstract class are required to be abstract, whereas all methods in an Interface are not. C. Abstract methods do not provide implementations D. A class that contains abstract methods must be declared as an abstract class even if it contains concrete (non-abstract) methods When a class implements an interface, the class must implement at least one of the methods in the interface. concrete class can implement one Abstract class and multiple Interfaces. G. Classes that can be used to instantiate objects are called concrete classes. H. Java and C# do not allow derived classes to inherit from more than one interface, but do F. A allow a class to implement any number of Abstract classes. An interface can extend one or more other interfaces to create a more elaborate interface that other classes can implement
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started