A-OOP Assignment 2 SUNAIM
A-OOP Assignment 2 SUNAIM
T
ADVANCED OBJECT ORIENTED PROGRAMMING
( CE- 206 )
Submitted By:
N ame # SUNAIM ABDULLAH
R oll N umber # 2 0 2 0 - C E - 0 41
Submitted To:
MISS UMM-E-LAILA
http://www.ssuet.edu.pk
ASSIGNMENT#2
QUESTION#1:
The Student table is defined as follows:
create table Student
( firstname varchar(25),
mi char(1),
lastname varchar(25),
studentID varchar(25),
year int(1)
, city varchar(20),
email varchar(30) );
Demonstration:
In this snapshot, 6 functionalities are given in terms of buttons namely first,
next, last, insert, clear and update. Beneath it, there is a form which consists of
fields like first name, last name, student ID etc. First, next and last buttons are
used to show the records of the table according to the requirements. First will
filter the details of the first user entered with ID number 1. Next will filter the
details entered afterwards and the last button is used to filter last record of the
table. Insert button is used to enter the new record in the table. Clear button is
for resetting all the fields. The purpose is that if you have entered incorrect data
in all the fields then no need to clear the field one by one. Clear button will
2
AOOP SUNAIM ABDULLAH [2020-CE-041]
automatically reset all the fields filled. Last one is update, update is for editing
any inserted record that you have entered in the past.
QUESTION#2:
Prepare a TCP client/server application that will communicate over the network and
exchange data. The server will start listening for a transmission from the client. The client
will then start and contact the server (IP address: 127.0.0.1 and port number: 6666). The
client will pass the server a 2 integer numbers i.e user name (e.g. “AliKhan”) up to 7
characters in length. On receiving a string from a client, the server should:
1. Reverse all the characters, and 2. Reverse the capitalization of the strings (“AliKhan”
would now become “NAHKILA”)
import java.net.*;
import java.util.Scanner;
import java.io.*;
3
AOOP SUNAIM ABDULLAH [2020-CE-041]
} catch (Exception e) {
System.out.println(e);
}
}
}
import java.net.*;
import java.util.Scanner;
import java.io.*;
public class Server {
public static void main(String[] args) throws IOException {
try{ ServerSocket ss=new ServerSocket(333);
Socket s=ss.accept();//establishes connection
Scanner sc=new Scanner(s.getInputStream());
String in=sc.nextLine();
in=in.toLowerCase();
in=in.toUpperCase();
ps.println(in);
}catch(Exception e){System.out.println(e);}
}}
OUTPUT:
4
AOOP SUNAIM ABDULLAH [2020-CE-041]
QUESTION#3:
Produce an implement a Queue class whose add and remove methods are synchronized.
Supply one thread, called the producer, which keeps inserting strings into the queue as long
as there are fewer than 10 elements in it. When the queue gets too full, the thread waits.
Supply a second thread, called the consumer that keeps removing and printing strings from
the queue as long as the queue is not empty. When the queue is empty, the thread waits. Both
the consumer and producer threads should run for 10 iterations.
SOURCE CODE:
package queue;
import java.lang.Thread;
}
Thread.sleep(1000);
}catch (InterruptedException e) {
System.out.println(Name + " thread Interrupted");
}
System.out.println(Name + " thread exiting.");
}
5
AOOP SUNAIM ABDULLAH [2020-CE-041]
}}
OUTPUT: