Java Programming: Assessment-5
Java Programming: Assessment-5
Java Programming: Assessment-5
Assessment-5
NAME: Asmit Gupta
REG. NO.:18BCE0904
SLOT: L53+L54
FACULTY: ASIS KUMAR TRIPATHY
Q1. Write a program to demonstrate the object serialization and
deserialization when one object holds information about the salary
the employees of an organization.
Code:-
import java.io.*;
// Default constructor
public Employee(String name, int age, int salary)
{
this.name = name;
this.age = age;
this.salary = salary;
}
out.writeObject(object);
out.close();
file.close();
catch(IOException ex)
{
System.out.println("IOException is caught");
}
// Deserialization
try
{
FileInputStream file = new FileInputStream(filename);
ObjectInputStream in = new ObjectInputStream(file);
object1 = (Employee)in.readObject();
in.close();
file.close();
catch(IOException ex)
{
System.out.println("IOException is caught");
}
catch(ClassNotFoundException ex)
{
System.out.println("ClassNotFoundException is caught");
}
}
}
OUTPUT:-
Q2:- Create a LinkedHashmap and store the name and regd no of your
ten number of friends, finally delete one of your friend data from the
map
CODE:-
import java.util.*;
newmap.put("18bce0904", "asmit");
newmap.put("18bce0956", "anmol");
newmap.put("18bce0456", "ankit");
newmap.put("18bce2254", "yash");
newmap.put("18bee2044", "aman");
System.out.println("Mappings of LinkedHashMap : "+ newmap);
System.out.println();
newmap.remove("18bce904");
System.out.println("Updated mappings: " + newmap);
System.out.println();
}
}
OUTPUT:-
Q3:- Show one stage using JAVAFX where your name will be displayed
in red color
CODE:-
import javafx.application.Application;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.paint.Color;
import javafx.stage.Stage;
import javafx.scene.text.Font;
import javafx.scene.text.FontPosture;
import javafx.scene.text.FontWeight;
import javafx.scene.text.Text;
OUTPUT:-
Q4:- Show one stage using JAVAFX where your name will be displayed
in red color.
CODE:-
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.*;
import javafx.scene.layout.*;
import javafx.stage.Stage;
@Override
public void start(Stage primaryStage) throws Exception {
primaryStage.setTitle("ASMIT GUPTA");
gridPane.add(r, 0, 0, 4, 1);
gridPane.add(button1, 0, 1, 1, 1);
gridPane.add(button2, 1, 1, 1, 1);
gridPane.add(button3, 2, 1, 1, 1);
gridPane.add(buttonmul, 3, 1, 1, 1);
gridPane.add(button4, 0, 2, 1, 1);
gridPane.add(button5, 1, 2, 1, 1);
gridPane.add(button6, 2, 2, 1, 1);
gridPane.add(buttonmin, 3, 2, 1, 1);
gridPane.add(button7, 0, 3, 1, 1);
gridPane.add(button8, 1, 3, 1, 1);
gridPane.add(button9, 2, 3, 1, 1);
gridPane.add(buttondiv, 3, 3, 1, 1);
gridPane.add(button0, 0, 4, 1, 1);
gridPane.add(buttonp, 1, 4, 1, 1);
gridPane.add(buttone, 2, 4, 1, 1);
gridPane.add(buttonac, 3, 4, 1, 1);
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import javafx.application.Application;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.stage.Stage;
public class App extends Application {
@Override
public void start(Stage stage) throws FileNotFoundException {
Image imagepp = new Image(new FileInputStream("C:\\Users\\TEMP.LAPTOP-
KROJC7S1.009\\Pictures\\Screenshots\\pp.jpeg"));
Image imagefb = new Image(new FileInputStream("C:\\Users\\TEMP.LAPTOP-
KROJC7S1.009\\Pictures\\Screenshots\\fb.png"));
Image imageinst = new Image(new FileInputStream("C:\\Users\\TEMP.LAPTOP-
KROJC7S1.009\\Pictures\\Screenshots\\instagram.png"));
Image imagesp = new Image(new FileInputStream("C:\\Users\\TEMP.LAPTOP-
KROJC7S1.009\\Pictures\\Screenshots\\snapchat.png"));
Image imagewh = new Image(new FileInputStream("C:\\Users\\TEMP.LAPTOP-
KROJC7S1.009\\Pictures\\Screenshots\\whatsapp.png"));
Image imagewo = new Image(new FileInputStream("C:\\Users\\TEMP.LAPTOP-
KROJC7S1.009\\Pictures\\Screenshots\\word.png"));
Image imageyo = new Image(new FileInputStream("C:\\Users\\TEMP.LAPTOP-
KROJC7S1.009\\Pictures\\Screenshots\\youtube.png"));