Sure, I can help you with those questions! Here are the solutions:
1. Arrays:
```java
import java.util.Scanner;
public class ArraySum {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int[][] myArray = new int[4][4];
int[] rowSum = new int[4];
int[] colSum = new int[4];
System.out.println("Enter 16 values:");
// Reading values into the array
for (int i = 0; i < 4; i++) {
for (int j = 0; j < 4; j++) {
myArray[i][j] = scanner.nextInt();
rowSum[i] += myArray[i][j];
colSum[j] += myArray[i][j];
}
}
// Printing the arrays
System.out.println("Row Sums:");
for (int i = 0; i < 4; i++) {
System.out.print(rowSum[i] + " ");
}
System.out.println("\nColumn Sums:");
for (int i = 0; i < 4; i++) {
System.out.print(colSum[i] + " ");
}
}
}
```
2. ArrayList class:
```java
import java.util.ArrayList;
import java.util.Scanner;
public class NamesBook {
public static void main(String[] args) {
ArrayList<String> namesBook = new ArrayList<>();
Scanner scanner = new Scanner(System.in);
System.out.println("Enter names (type 'done' to finish):");
// Reading names into the ArrayList
String name = scanner.nextLine();
while (!name.equalsIgnoreCase("done")) {
namesBook.add(name);
name = scanner.nextLine();
}
// Finding the longest name
String longestName = "";
for (String friend : namesBook) {
if (friend.length() > longestName.length()) {
longestName = friend;
}
}
// Printing number of friends and longest name
System.out.println("Number of friends: " + namesBook.size());
System.out.println("Longest name: " + longestName);
}
}
```
3. Inheritance:
```java
public class HospitalPerson {
private String name;
private String idNumber;
public HospitalPerson(String name, String idNumber) {
this.name = name;
this.idNumber = idNumber;
}
public void printInfo() {
System.out.println("Name: " + name);
System.out.println("ID Number: " + idNumber);
}
}
public class Doctor extends HospitalPerson {
private String specialty;
public Doctor(String name, String idNumber, String specialty) {
super(name, idNumber);
this.specialty = specialty;
}
@Override
public void printInfo() {
super.printInfo();
System.out.println("Specialty: " + specialty);
}
}
public class Nurse extends HospitalPerson {
private int maxDutyHours;
public Nurse(String name, String idNumber, int maxDutyHours) {
super(name, idNumber);
this.maxDutyHours = maxDutyHours;
}
@Override
public void printInfo() {
super.printInfo();
System.out.println("Max Duty Hours: " + maxDutyHours);
}
}
```
I hope these solutions help you understand the concepts better! If you have any questions or need further clarification, feel free to ask. Additionally, if you ever need
help with programming assignment, there are resources available online like
programminghomeworkhelp.com, where you can seek help with programming assignment.