Open Santhosh-KrishnanM opened 2 months ago
Batch 2– Exercise V Object Class and Lambda Expression Ex-5
Write a Java program to design class Employee (empId,name,designation,deparment,salary). Design methods for the following a. Override equals() method to check is there any duplicate employee object. b. Override toString method to display the output as [empId,name,designation,deparment,salary] c. Override hashCode() method to find the hashvalue of the object and use it for indexing the student object created. The index must be used to store the input into an array of object.
Write the following methods that return a lambda expression for the following operations: a. Convert a list of strings to uppercase if the string length is even and to lowercase if the string length is odd b. Sort the strings based on their lengths in ascending order c. Remove duplicates from a list of String
import javax.swing.; import java.awt.; //import java.awt.Event.*;
class Studentpersonaldet{ public static void main(String[] args){ JFrame f = new JFrame("Student Details"); f.setSize(400,180); f.setDefaultCloseOperation(f.EXIT_ON_CLOSE); JPanel p1,p2; p1 = new JPanel(); p1.setLayout(new GridLayout(4,2)); p1.setBorder(BorderFactory.createTitledBorder("Personal Details")); p1.add(new JLabel("Student Name: ")); p1.add(new JTextField(25)); p1.add(new JLabel("Date of Birth: ")); p1.add(new JTextField(15)); p1.add(new JLabel("Age: ")); p1.add(new JTextField(5)); p1.add(new JLabel("Gender: ")); JRadioButton jb1 = new JRadioButton(); jb1.addItem("Male"); jb1.addItem("Female"); p1.add(jb1); f.add(p1);
p2 = new JPanel();
p2.setLayout(new GridLayout(4,2));
p2.setBorder(BorderFactory.createTitledBorder("Academic Details"));
p2.add(new JLabel("Department: "));
p2.add(new JTextField(10));
p2.add(new JLabel("Year: "));
JRadioBu
JRadioButton jb2 = new JRadioButton();
jb2.addItem("I");
jb2.addItem("II");
jb2.addItem("III");
jb2.addItem("IV");
p2.add(jb2);
p2.add(new JTextField(5));
p2.add(new JLabel("Semester: "));
p2.add(new JTextField(5));
p2.add(new JLabel("CGPA: "));
p2.add(new JTextField(10));
f.add(p2);
JPanel p3 = new JPanel();
p3.setLayout(new FlowLayout());
p3.add(new JButton("Save"));
p3.add(new JButton("Cancel"));
f.add(p3);
f.setLocationRelativeTo(null);
f.setVisible(true);
}
}
import javax.swing.; import java.awt.; //import java.awt.Event.*;
class Studentpersonaldet{ public static void main(String[] args){ JFrame f = new JFrame("Student Details"); f.setSize(400,180); f.setDefaultCloseOperation(f.EXIT_ON_CLOSE); JPanel p1,p2; p1 = new JPanel(); p1.setLayout(new GridLayout(4,2)); p1.setBorder(BorderFactory.createTitledBorder("Personal Details")); p1.add(new JLabel("Student Name: ")); p1.add(new JTextField(25)); p1.add(new JLabel("Date of Birth: ")); p1.add(new JTextField(15)); p1.add(new JLabel("Age: ")); p1.add(new JTextField(5)); p1.add(new JLabel("Gender: ")); JRadioButton jb1 = new JRadioButton(); jb1.addItem("Male"); jb1.addItem("Female"); p1.add(jb1); f.add(p1);
p2 = new JPanel();
p2.setLayout(new GridLayout(4,2));
p2.setBorder(BorderFactory.createTitledBorder("Academic Details"));
p2.add(new JLabel("Department: "));
p2.add(new JTextField(10));
p2.add(new JLabel("Year: "));
JRadioBu
JRadioButton jb2 = new JRadioButton();
jb2.addItem("I");
jb2.addItem("II");
jb2.addItem("III");
jb2.addItem("IV");
p2.add(jb2);
p2.add(new JTextField(5));
p2.add(new JLabel("Semester: "));
p2.add(new JTextField(5));
p2.add(new JLabel("CGPA: "));
p2.add(new JTextField(10));
f.add(p2);
JPanel p3 = new JPanel();
p3.setLayout(new FlowLayout());
p3.add(new JButton("Save"));
p3.add(new JButton("Cancel"));
f.add(p3);
f.setLocationRelativeTo(null);
f.setVisible(true);
}
}
Ex 1 and 2 Classes_and_objects_Batch1_1724495224773.docx Arrays_and_Strings_Batch1_1724495191265.docx