Java Assignment FINAL 2022
Java Assignment FINAL 2022
NO
BABCOCK UNIVERSITY
DEPARTMENT OF SOFTWARE ENGINEERING
a) Declare and initialize a 2D array, magicSquare, to hold the words illustrated above
b) Write a method, displayRow, that accepts the magicSquare array and a row number and displays
the word in that row.
c) Write a method, displayColumn, that accepts the magicSquare array and column number and
displays the word in that column
d) In a two dimensional array named truthTable, what is the difference between these two
references: truthTable.length and truthTable[0].length
8) Create a class called Employee that includes three pieces of information as data members—a first
name (type string), a last name (type string) and a monthly salary (type int). Your class should have
a constructor that initializes the three data members. Provide a set and a get methods for each data
member. If the monthly salary is not positive, set it to 0. Write a test program that demonstrates class
Employee’s capabilities. Create two Employee objects and display each object’s yearly salary. Then
give each Employee a 10 % raise and display each Employee’s yearly salary again.
Page 2 of 2 PAPER REF. NO
Note: Encapsulation requires you to hide your data, while you expose the behaviours
9) Consider the following classes and arrange them into an inheritance hierarchy:
10) Implement a code to find the largest element from an arbitrary linear array.