Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Generic Method Exercise 1 1- Create class Student that has the following data: id(int), name(string), gpa (double), generate constructor, setter/getter and toString methods. 2- Create

Generic Method Exercise 1

1- Create class Student that has the following data: id(int), name(string), gpa (double), generate constructor, setter/getter and toString methods.

2- Create class Car that has the following data: plateNo(int), brand(String), generate constructor, setter/getter and toString methods.

3- Create a new class, call it GM_Test, in the class create

a- generic method called swapFirstLast, it receives a generic type array, and swaps the last element in the array with the first one.

b- generic method called reverse, it receives a generic type array, and reverse the order of the elements in the array.

c- Generic method shift that receives an a generic type array and shifts its element one position to the left as depicted by the following figure S

d- Generic method print that receives a generic type array and prints its elements.

e- Create main method, and in the method create the following arrays and fill them with elements:

Array of students (3 elements)

Array of cars (4 elements)

f- In the main method, call the methods in a,b,c on the array of students and cars. Each time, print the array before you call the method, then print it after calling the method to see its effects.

g- Create the following arrays: int intArray[]={4,1,7,9};

char chArray[]={a,b,c,d};

call the methods in a,b,c on the array of intArray and chArray. Each time, print the array before you call the method, then print it after calling the method to see its effects.

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

DB2 9 For Linux UNIX And Windows Advanced Database Administration Certification Certification Study Guide

Authors: Roger E. Sanders, Dwaine R Snow

1st Edition

1583470808, 978-1583470800

More Books

Students also viewed these Databases questions

Question

9. Understand the phenomenon of code switching and interlanguage.

Answered: 1 week ago

Question

Prepare an ID card of the continent Antarctica?

Answered: 1 week ago

Question

Question Can plan participants borrow from a VEBA?

Answered: 1 week ago