1, Import Jav
1, Import Jav
Group assignment
Group name. Id no
1, import java.util.Scanner;
max = num2;
max = num3;
min = num2;
min = num3;
}
2, Here is a Java program that accepts 10 constant integer numbers and computes the square root and
power of 2 of the numbers:
```
import java.util.Scanner;
numbers[i] = scanner.nextInt();
}
for (int i = 0; i < numbers.length; i++) {
```
First, we create a Scanner object to read user input. We also create an array called `numbers` that will
store the 10 numbers entered by the user.
We then prompt the user to enter 10 numbers and use a loop to read and store them in the `numbers`
array.
Finally, we use another loop to compute the square root and power of 2 of each number in the
`numbers` array using the `Math.sqrt()` and `Math.pow()` functions, respectively, and print the results
to the console.
```
3, import java.util.ArrayList;
this.fullName = fullName;
this.idNo = idNo;
this.gender = gender;
this.department = department;
return fullName;
return idNo;
return gender;
return department;
}
public static void main(String[] args) {
System.out.println("FullName\tIDNO\t\tGender\tDepartment");
```
Output:
```
System.out.print("Name: ");
studentNames[i] = input.nextLine();
courseNames[i] = input.nextLine();
System.out.print("Score: ");
scores[i] = input.nextInt();
gradePoints[i] = input.nextLine();
System.out.println("\nStudent Information:");
System.out.print("Grade: ");
System.out.println("A");
System.out.println("B");
System.out.println("C");
System.out.println("D");
} else {
System.out.println("F");
}
5, Abstract Window Toolkit (AWT) is a collection of classes that Java
developers can use to create graphical user interfaces (GUI) for their
applications. It provides a way for developers to create windows, dialogs,
buttons, menus, and other common GUI components that users interact with.
AWT has been around since the early days of Java and is still used in many Java
applications today.
Java Virtual Machine (JVM) is the foundation of the Java platform. It is a virtual machine that is
responsible for executing Java bytecode, which is the compiled form of Java source code. JVM takes
care of memory management, garbage collection, and other low-level details that make Java a portable
and secure programming language. JVM also provides a sandbox environment that isolates Java
applications from the operating system and other applications running on the same machine.
Java applets are small programs that run inside web browsers. They were popular in the early days of
the web and were used to add interactivity to static HTML pages. Applets are still used today, but their
popularity has decreased due to security concerns and the rise of web technologies like JavaScript and
HTML5.
Java Swing is a set of GUI components that were introduced in Java 2. Swing is written entirely in Java
and offers a more modern and flexible approach to GUI development compared to AWT. Swing
provides a wide range of components, from basic buttons and labels to complex tables and trees. It is
widely used by Java developers today.
Pros of AWT:
- AWT components have a consistent look and feel across different platforms.
Cons of AWT:
- AWT components have limited functionality compared to Swing.
- It lacks support for modern UI features like transparency, alpha blending, and custom skins.
- AWT has a limited selection of layout managers, making it difficult to create complex UI layouts.
Pros of JVM:
- JVM provides a high level of portability, allowing Java code to run on any platform that has a JVM
installed.
- It offers a secure sandbox environment that isolates Java code from the operating system and other
applications.
- JVM provides automatic memory management and garbage collection, making it easy to write
memory-safe code.
Cons of JVM:
- Applets can run on any machine that has a JVM installed, making them highly portable.
- They are easy to develop, as they can reuse existing Java code.
- Applets can offer a rich and interactive user experience, similar to native desktop applications.
- Applets require user permission to run, making it difficult to use them for certain applications.
- Swing provides a wide range of GUI components that are highly customizable.
- It offers support for modern UI features like transparency, alpha blending, and custom skins.
- Swing has a wide selection of layout managers, making it easy to create complex UI layouts.