package p1; public class Derivation extends Protection { public Derivation() { System.out.println("Derived class constructor");

Size: px
Start display at page:

Download "package p1; public class Derivation extends Protection { public Derivation() { System.out.println("Derived class constructor");"

Transcription

1 PROGRAM:1 WAP to implement the packages //package 1: package p1; public class Protection int n=1; public int n_pub=2; private int n_pri=3; protected int n_pro=4; public Protection () System.out.println("Base class constructor"); System.out.println("The value of n is: "+n); System.out.println("The value of n_pub is: "+n_pub); System.out.println("The value of n_pri is: "+n_pri); System.out.println("The value of n_pro is: "+n_pro); package p1; public class Derivation extends Protection public Derivation() System.out.println("Derived class constructor"); System.out.println("The value of n is: "+n); System.out.println("The value of n_pub is: "+n_pub); System.out.println("The value of n_pri is private and so not available to outside class"); System.out.println("The value of n_pro is: "+n_pro); package p1; public class SamePackage public SamePackage() Protection p = new Protection();

2 System.out.println("Same package class constructor"); System.out.println("The value of n is: "+p.n); System.out.println("The value of n_pub is: "+p.n_pub); System.out.println("The value of n_pri is private so not available to outside class"); System.out.println("The value of n_pro is: "+p.n_pro); package p1; public class Demo public static void main(string s[]) Protection ob1= new Protection(); Derivation ob2= new Derivation(); SamePackage ob3= new SamePackage(); OUTPUT: Base class constructor The value of n_pri is: 3 Derived class constructor The value of n_pri is private and so not available to outside class Base class constructor The value of n_pri is: 3 Same package class constructor The value of n_pri is private and so not available to outside class The value of n_pro is:

3 //Package 2: package p2; class Protection1 extends p1.protection public Protection1() System.out.println("other Package derived class"); System.out.println("The value of n_pub is: "+n_pub); System.out.println("The value of n_pri is private "); System.out.println("The value of n is not visible "); System.out.println("The value of n_pro is: "+n_pro); package p2; import p1.*; public class OtherPackage public OtherPackage() Protection p=new Protection(); System.out.println("The value of n_pub is: "+p.n_pub); System.out.println("The value of n_pri is private,p.n_pri"); System.out.println("The value of n is not visible "); System.out.println("The value of n_pro is: protected,p.n_pro"); package p2; public class Demo1 public static void main(string args[]) Protection1 obj= new Protection1(); OtherPackage obj1= new OtherPackage();

4 OUTPUT: C:\Documents and Settings\User\Desktop\javapgms>java p2.demo1 Base class constructor The value of n_pri is: 3 other Package derived class The value of n_pri is private The value of n is not visible Base class constructor The value of n_pri is: 3 The value of n_pri is private,p.n_pri The value of n is not visible The value of n_pro is: protected,p.n_pro

5 PROGRAM:2(a) WAP to implement Multithreading using Runnable Interface class NewThread implements Runnable Thread t; NewThread() t= new Thread(this,"Demo Thread"); System.out.println("Child Thread:"+t); t.start(); public void run() try for(int i=5;i>0;i--) System.out.println("Child Thread:"+i); Thread.sleep(500); catch(interruptedexception ie) System.out.println("Child Interrupted"); System.out.println("Child Exited"); class ThreadDemo public static void main(string args[]) new NewThread(); try for(int i=5;i>0;i--) System.out.println("Main Thread"+i); Thread.sleep(1000); catch(interruptedexception ie) System.out.println("Main Interrupted"); System.out.println("Main Exiting");

6 OUTPUT: C:\Documents and Settings\User\Desktop\javapgms>java ThreadDemo Child Thread:Thread[Demo Thread,5,main] Main Thread5 Child Thread:5 Child Thread:4 Main Thread4 Child Thread:3 Child Thread:2 Main Thread3 Child Thread:1 Child Exited Main Thread2 Main Thread1 Main Exiting

7 PROGRAM:2(b) WAP to implement Multithreading by extending the Thread class class NewThread implements Runnable Thread t; NewThread() t= new Thread(this,"Demo Thread"); System.out.println("Child Thread:"+t); t.start(); public void run() try for(int i=5;i>0;i--) System.out.println("Child Thread:"+i); Thread.sleep(500); catch(interruptedexception ie) System.out.println("Child Interrupted"); System.out.println("Child Exited"); class ThreadDemo public static void main(string args[]) new NewThread(); try for(int i=5;i>0;i--) System.out.println("Main Thread"+i); Thread.sleep(1000); catch(interruptedexception ie) System.out.println("Main Interrupted"); System.out.println("Main Exiting");

8 OUTPUT: C:\Documents and Settings\User\Desktop\javapgms>java ThreadDemo Child Thread:Thread[Demo Thread,5,main] Main Thread5 Child Thread:5 Child Thread:4 Main Thread4 Child Thread:3 Child Thread:2 Main Thread3 Child Thread:1 Child Exited Main Thread2 Main Thread1 Main Exiting

9 PROGRAM:3 WAP to implement Server and connect to server through Client //MyServer.java import java.io.*; import java.util.*; import java.net.*; public class MyServer ServerSocket ss; Socket s; DataInputStream din; public MyServer() try System.out.println("Server started"); ss=new ServerSocket(8); s=ss.accept(); System.out.println("Client Connected"); din=new DataInputStream(s.getInputStream()); ServerChat(); catch(exception e) System.out.println(e); public void ServerChat()throws IOException String str; do str=din.readutf(); System.out.println("Client message:"+str); while(!str.equalsignorecase("stop")); public static void main(string args[]) new MyServer(); //MyClient.java import java.io.*; import java.util.*; import java.net.*;

10 public class MyClient Socket s; DataOutputStream dout; public MyClient() try s= new Socket("localhost",8); dout=new DataOutputStream(s.getOutputStream()); ClientChat(); catch(exception e) System.out.println(e); public void ClientChat()throws IOException BufferedReader br= new BufferedReader(new InputStreamReader(System.in)); String str1; do str1=br.readline(); dout.writeutf(str1); dout.flush(); while(!str1.equalsignorecase("stop")); public static void main(string args[]) new MyClient(); OUTPUT:

11

Java Networking. Ajay Khatri

Java Networking. Ajay Khatri Java Networking Ajay Khatri Java Networking Connecting two or more computing devices together so that we can share resources. Advantage of Java Networking Sharing resources Centralize software management

More information

Le L c e t c ur u e e 7 To T p o i p c i s c t o o b e b e co c v o e v r e ed e Multithreading

Le L c e t c ur u e e 7 To T p o i p c i s c t o o b e b e co c v o e v r e ed e Multithreading Course Name: Advanced Java Lecture 7 Topics to be covered Multithreading Thread--An Introduction Thread A thread is defined as the path of execution of a program. It is a sequence of instructions that

More information

Unit 1 Java Networking

Unit 1 Java Networking Q1. What is Server Socket? Discuss the difference between the Socket and ServerSocket class. The ServerSocket class (java.net) can be used to create a server socket. This object is used to establish communication

More information

04-Java Multithreading

04-Java Multithreading 04-Java Multithreading Join Google+ community http://goo.gl/u7qvs You can ask all your doubts, questions and queries by posting on this G+ community during/after webinar http://openandroidlearning.org

More information

MYcsvtu Notes. Java Programming Lab Manual

MYcsvtu Notes. Java Programming Lab Manual Java Programming Lab Manual LIST OF EXPERIMENTS 1. Write a Program to add two numbers using Command Line Arguments. 2. Write a Program to find the factorial of a given number using while statement. 3.

More information

Unit 4. Thread class & Runnable Interface. Inter Thread Communication

Unit 4. Thread class & Runnable Interface. Inter Thread Communication Unit 4 Thread class & Runnable Interface. Inter Thread Communication 1 Multithreaded Programming Java provides built-in support for multithreaded programming. A multithreaded program contains two or more

More information

Networking Code CSCI 201 Principles of Software Development

Networking Code CSCI 201 Principles of Software Development Networking Code CSCI 201 Principles of Software Development Jeffrey Miller, Ph.D. jeffrey.miller@usc.edu Server Networking Client Networking Program Outline USC CSCI 201L Server Software A server application

More information

JAVA. Lab 12 & 13: Multithreading

JAVA. Lab 12 & 13: Multithreading JAVA Prof. Navrati Saxena TA: Rochak Sachan Lab 12 & 13: Multithreading Outline: 2 What is multithreaded programming? Thread model Synchronization Thread Class and Runnable Interface The Main Thread Creating

More information

public static void main(string[] args) throws IOException { sock = new Socket(args[0], Integer.parseInt(args[1]));

public static void main(string[] args) throws IOException { sock = new Socket(args[0], Integer.parseInt(args[1])); Echo Client&Server Application EchoClient import java.net.*; import java.io.*; class EchoClient public static void main(string[] args) throws IOException if (args.length < 2) number>"); System.err.println("Usage:

More information

Practical No: 1 Aim: Demonstrate round - robin scheduling using threads.

Practical No: 1 Aim: Demonstrate round - robin scheduling using threads. Practical No: 1 Aim: Demonstrate round - robin scheduling using threads. Source Code: RR.java import java.io.*; class job implements Runnable int process_id, no_of_instr,time_quantum; Thread t; job(int

More information

INF 212 ANALYSIS OF PROG. LANGS CONCURRENCY. Instructors: Crista Lopes Copyright Instructors.

INF 212 ANALYSIS OF PROG. LANGS CONCURRENCY. Instructors: Crista Lopes Copyright Instructors. INF 212 ANALYSIS OF PROG. LANGS CONCURRENCY Instructors: Crista Lopes Copyright Instructors. Basics Concurrent Programming More than one thing at a time Examples: Network server handling hundreds of clients

More information

830512@itri.org.tw import java.net.socket; import java.net.serversocket; import java.io.ioexception; /* ---------- Java Server ---------- */ public class Nets static Socket thesocket; static ServerThread

More information

Multithreaded Programming

Multithreaded Programming Multithreaded Programming http://www.motifake.com/multi-tasking-baby-dishes-bath-wash-demotivational-posters-118837.html Traditional Multi-tasking - One CPU - Many users, each wishing to use a computer

More information

Multithreaded Programming

Multithreaded Programming Multithreaded Programming http://www.motifake.com/multi-tasking-baby-dishes-bath-wash-demotivational-posters-118837.html http://thechive.com/2014/01/15/champions-of-multitasking-35-photos/ www.funscrape.com/meme/62260

More information

Unit - IV Multi-Threading

Unit - IV Multi-Threading Unit - IV Multi-Threading 1 Uni Processing In the early days of computer only one program will occupy the memory. The second program must be in waiting. The second program will be entered whenever first

More information

BSc ( Hons) Computer Science with Network Security. Examinations for / Semester 2

BSc ( Hons) Computer Science with Network Security. Examinations for / Semester 2 BSc ( Hons) Computer Science with Network Security Cohort: BCNS/16B/FT Examinations for 2017 2018 / Semester 2 Resit Examinations for BCNS/15B/FT & BCNS/16A/FT MODULE: NETWORK PROGRAMMING MODULE CODE:

More information

Socket Programming(TCP & UDP) Sanjay Chakraborty

Socket Programming(TCP & UDP) Sanjay Chakraborty Socket Programming(TCP & UDP) Sanjay Chakraborty Computer network programming involves writing computer programs that enable processes to communicate with each other across a computer network. The endpoint

More information

JAVA and J2EE UNIT - 4 Multithreaded Programming And Event Handling

JAVA and J2EE UNIT - 4 Multithreaded Programming And Event Handling JAVA and J2EE UNIT - 4 Multithreaded Programming And Event Handling Multithreaded Programming Topics Multi Threaded Programming What are threads? How to make the classes threadable; Extending threads;

More information

FIFO PAGE REPLACEMENT : import java.io.*; public class FIFO {

FIFO PAGE REPLACEMENT : import java.io.*; public class FIFO { FIFO PAGE REPLACEMENT : import java.io.*; public class FIFO public static void main(string[] args) throws IOException BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int frames,

More information

Recursion. General Algorithm for Recursion. When to use and not use Recursion. Recursion Removal. Examples

Recursion. General Algorithm for Recursion. When to use and not use Recursion. Recursion Removal. Examples Recursion General Algorithm for Recursion When to use and not use Recursion Recursion Removal Examples Comparison of the Iterative and Recursive Solutions Exercises Unit 19 1 General Algorithm for Recursion

More information

Chapter 8 Threads Zindell Technologies, Ltd. Question 1: Which one statement below is true concerning the following code?

Chapter 8 Threads Zindell Technologies, Ltd. Question 1: Which one statement below is true concerning the following code? 1 Chapter 8 Threads Question 1: Which one statement below is true concerning the following code? 1. class Hevron extends java.util.vector implements Runnable 2. 3. public void run(int counter) 4. 3. System.out.println("in

More information

INHERITANCE Inheritance Basics extends extends

INHERITANCE Inheritance Basics extends extends INHERITANCE Inheritance is one of the cornerstones of object-oriented programming because it allows the creation of hierarchical classifications. Using inheritance, you can create a general class that

More information

Multithreaded Programming

Multithreaded Programming Multithreaded Programming Multithreaded programming basics Concurrency is the ability to run multiple parts of the program in parallel. In Concurrent programming, there are two units of execution: Processes

More information

Amity School of Engineering

Amity School of Engineering Amity School of Engineering B.Tech., CSE(5 th Semester) Java Programming Topic: Multithreading ANIL SAROLIYA 1 Multitasking and Multithreading Multitasking refers to a computer's ability to perform multiple

More information

Solutions to Sample JAC444 Midterm Test

Solutions to Sample JAC444 Midterm Test Solutions to Sample JAC444 Midterm Test 1-2016 A. Theory (10 marks = 5 marks + 5 marks) 1. When can one implement a deep cloning in Java? see deep cloning lecture 3 2. What are the differences between

More information

Object-Oriented Programming in Java

Object-Oriented Programming in Java CSCI/CMPE 3326 Object-Oriented Programming in Java 1. Socket Programming Dongchul Kim Department of Computer Science University of Texas Rio Grande Valley Two types of TCP Socket java.net.serversocket

More information

Module - 4 Multi-Threaded Programming

Module - 4 Multi-Threaded Programming Terminologies Module - 4 Multi-Threaded Programming Process: A program under execution is called as process. Thread: A smallest component of a process that can be executed independently. OR A thread is

More information

CS September 2017

CS September 2017 Machine vs. transport endpoints IP is a network layer protocol: packets address only the machine IP header identifies source IP address, destination IP address Distributed Systems 01r. Sockets Programming

More information

Java Socket Application. Distributed Systems IT332

Java Socket Application. Distributed Systems IT332 Java Socket Application Distributed Systems IT332 Outline Socket Communication Socket packages in Java Multithreaded Server Socket Communication A distributed system based on the client server model consists

More information

CS 355. Computer Networking. Wei Lu, Ph.D., P.Eng.

CS 355. Computer Networking. Wei Lu, Ph.D., P.Eng. CS 355 Computer Networking Wei Lu, Ph.D., P.Eng. Chapter 2: Application Layer Overview: Principles of network applications? Introduction to Wireshark Web and HTTP FTP Electronic Mail: SMTP, POP3, IMAP

More information

3. Remote Procedure Call

3. Remote Procedure Call 3. Remote Procedure Call Master II Software Engineering Imed Bouchrika Dept of Mathematics & Computer Science University of Souk-Ahras imed@imed.ws Imed Bouchrika. Distributed Objects, Uni of Souk-Ahras

More information

Internet Technology 2/7/2013

Internet Technology 2/7/2013 Sample Client-Server Program Internet Technology 02r. Programming with Sockets Paul Krzyzanowski Rutgers University Spring 2013 To illustrate programming with TCP/IP sockets, we ll write a small client-server

More information

UNIT IV MULTITHREADING AND GENERIC PROGRAMMING

UNIT IV MULTITHREADING AND GENERIC PROGRAMMING UNIT IV MULTITHREADING AND GENERIC PROGRAMMING Differences between multithreading and multitasking, thread life cycle, creating threads, creating threads, synchronizing threads, Inter-thread communication,

More information

JAVA - MULTITHREADING

JAVA - MULTITHREADING JAVA - MULTITHREADING http://www.tutorialspoint.com/java/java_multithreading.htm Copyright tutorialspoint.com Java is amultithreaded programming language which means we can develop mult it hreaded program

More information

FORTH SEMESTER DIPLOMA EXAMINATION IN ENGINEERING/ TECHNOLIGY- MARCH, 2012 OOP THROUGH JAVA (Common to CT, CM and IF)

FORTH SEMESTER DIPLOMA EXAMINATION IN ENGINEERING/ TECHNOLIGY- MARCH, 2012 OOP THROUGH JAVA (Common to CT, CM and IF) TED (10)-3069 (REVISION-2010) Reg. No.. Signature. FORTH SEMESTER DIPLOMA EXAMINATION IN ENGINEERING/ TECHNOLIGY- MARCH, 2012 OOP THROUGH JAVA (Common to CT, CM and IF) (Maximum marks: 100) [Time: 3 hours

More information

MYcsvtu Notes. Experiment-1. AIM: Write a program to implement fiestal cipher structure PROGRAM: import java.io.*; class functions

MYcsvtu Notes. Experiment-1. AIM: Write a program to implement fiestal cipher structure PROGRAM: import java.io.*; class functions Experiment-1 AIM: Write a program to implement fiestal cipher structure PROGRAM: import java.io.*; class functions String Xor(String s1,string s2) char s1array[]=s1.tochararray(); char s2array[]=s2.tochararray();

More information

CSE 660 Lab 7. Submitted by: Arumugam Thendramil Pavai. 1)Simple Remote Calculator. Server is created using ServerSocket class of java. Server.

CSE 660 Lab 7. Submitted by: Arumugam Thendramil Pavai. 1)Simple Remote Calculator. Server is created using ServerSocket class of java. Server. CSE 660 Lab 7 Submitted by: Arumugam Thendramil Pavai 1)Simple Remote Calculator Server is created using ServerSocket class of java Server.java import java.io.ioexception; import java.net.serversocket;

More information

Reading from URL. Intent - open URL get an input stream on the connection, and read from the input stream.

Reading from URL. Intent - open URL  get an input stream on the connection, and read from the input stream. Simple Networking Loading applets from the network. Applets are referenced in a HTML file. Java programs can use URLs to connect to and retrieve information over the network. Uniform Resource Locator (URL)

More information

Multi-threaded Web Server (Assignment 1) Georgios Georgiadis

Multi-threaded Web Server (Assignment 1) Georgios Georgiadis Multi-threaded Web Server (Assignment 1) Georgios Georgiadis Overview Multi-threaded Web Server What to do and how to do it HTTP messages Processes and threads ComputerComm '09 2 Multi-threaded Web Server

More information

Synchronization synchronization.

Synchronization synchronization. Unit 4 Synchronization of threads using Synchronized keyword and lock method- Thread pool and Executors framework, Futures and callable, Fork-Join in Java. Deadlock conditions 1 Synchronization When two

More information

Unit 5 - Exception Handling & Multithreaded

Unit 5 - Exception Handling & Multithreaded Exceptions Handling An exception (or exceptional event) is a problem that arises during the execution of a program. When an Exception occurs the normal flow of the program is disrupted and the program/application

More information

CS2307 NETWORKS LAB 1. Programs using TCP Sockets (like date and time server & client, echo server & client, etc.) 2. Programs using UDP Sockets

CS2307 NETWORKS LAB 1. Programs using TCP Sockets (like date and time server & client, echo server & client, etc.) 2. Programs using UDP Sockets CS2307 NETWORKS LAB 1. Programs using TCP Sockets (like date and time server & client, echo server & client, etc.) 2. Programs using UDP Sockets (like simple DNS) 3. Programs using Raw sockets (like packet

More information

CSCD 330 Network Programming

CSCD 330 Network Programming CSCD 330 Network Programming Lecture 8 Client-Server Programming Threads Winter 2015 Reading: Chapter 2, Relevant Links Some Material in these slides from J.F Kurose and K.W. Ross All material copyright

More information

Advanced Programming Methods. Lecture 6 - Concurrency in Java (1)

Advanced Programming Methods. Lecture 6 - Concurrency in Java (1) Advanced Programming Methods Lecture 6 - Concurrency in Java (1) Overview Introduction Java threads Java.util.concurrent References NOTE: The slides are based on the following free tutorials. You may want

More information

A sample print out is: is is -11 key entered was: w

A sample print out is: is is -11 key entered was: w Lab 9 Lesson 9-2: Exercise 1, 2 and 3: Note: when you run this you may need to maximize the window. The modified buttonhandler is: private static class ButtonListener implements ActionListener public void

More information

Principles, Models, and Applications for Distributed Systems M

Principles, Models, and Applications for Distributed Systems M Università degli Studi di Bologna Facoltà di Ingegneria Principles, Models, and Applications for Distributed Systems M Lab assignment 4 (worked-out) Connection-oriented Java Sockets Luca Foschini Winter

More information

Principles, Models, and Applications for Distributed Systems M

Principles, Models, and Applications for Distributed Systems M Università degli Studi di Bologna Facoltà di Ingegneria Principles, Models, and Applications for Distributed Systems M Exercitation 3 Connected Java Sockets Jacopo De Benedetto Distributed architecture

More information

Java Networking (sockets)

Java Networking (sockets) Java Networking (sockets) Rui Moreira Links: http://java.sun.com/docs/books/tutorial/networking/toc.html#sockets http://www.javaworld.com/javaworld/jw-12-1996/jw-12-sockets_p.html Networking Computers

More information

Exp 6: Develop Java programs to implement Interfaces and Packages. Apply Exception handling and implement multithreaded programs.

Exp 6: Develop Java programs to implement Interfaces and Packages. Apply Exception handling and implement multithreaded programs. CO504.3 CO504.4 Develop Java programs to implement Interfaces and Packages. Apply Exception handling and implement multithreaded programs. CO504.5 CO504.6 Implement Graphics programs using Applet. Develop

More information

Programming Java. Multithreaded Programming

Programming Java. Multithreaded Programming Programming Multithreaded Programming Incheon Paik 1 Contents An Overview of Threads Creating Threads Synchronization Deadlock Thread Communication 2 An Overview of Threads What is a Thread? A sequence

More information

Topic 10: Network Programming

Topic 10: Network Programming Topic 10: Network Programming Client-Server Model Host and Port Socket Implementing Client Implementing Server Implementing Server for Multiple Clients Client-Server Model Clients Request a server to provide

More information

Input from Files. Buffered Reader

Input from Files. Buffered Reader Input from Files Buffered Reader Input from files is always text. You can convert it to ints using Integer.parseInt() We use BufferedReaders to minimize the number of reads to the file. The Buffer reads

More information

BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); 2.A. Design a superclass called Staff with details as StaffId, Name, Phone, Salary. Extend this class by writing three subclasses namely Teaching (domain, publications), Technical (skills), and Contract

More information

JAVA - NETWORKING (SOCKET PROGRAMMING)

JAVA - NETWORKING (SOCKET PROGRAMMING) JAVA - NETWORKING (SOCKET PROGRAMMING) http://www.tutorialspoint.com/java/java_networking.htm Copyright tutorialspoint.com The term network programming refers to writing programs that execute across multiple

More information

TCP and UDP Socket Programming in JAVA TCP Socket Programming 1. Write code for Client and save in GreetingClient.java

TCP and UDP Socket Programming in JAVA TCP Socket Programming 1. Write code for Client and save in GreetingClient.java TCP Socket Programming 1. Write code for Client and save in GreetingClient.java // File Name GreetingClient.java public class GreetingClient public static void main(string [] args) String servername =

More information

Previous lecture: threads G51PRG: Introduction to Programming Second semester Lecture 12 URL

Previous lecture: threads G51PRG: Introduction to Programming Second semester Lecture 12 URL Previous lecture: threads G51PRG: Introduction to Programming Second semester Lecture 12 What is a thread Why use multiple threads Issues and problems involved Java threads Natasha Alechina School of Computer

More information

Assignment -3 Source Code. Student.java

Assignment -3 Source Code. Student.java import java.io.serializable; Assignment -3 Source Code Student.java public class Student implements Serializable{ public int rollno; public String name; public double marks; public Student(int rollno,

More information

GlobalLogic Technical Question Paper

GlobalLogic Technical Question Paper GlobalLogic Technical Question Paper What is the output of the following code when compiled and run? Select two correct answers. public class Question01 { public static void main(string[] args){ int y=0;

More information

Sockets and RMI. CS151 Chris Pollett Dec. 5, 2005.

Sockets and RMI. CS151 Chris Pollett Dec. 5, 2005. Sockets and RMI CS151 Chris Pollett Dec. 5, 2005. Outline Echo Server with Multiple Clients Client pull/server push Remote Method Invocation Proxy Pattern Echo Server with Multiple Clients public class

More information

Advanced Object-oriented Programming

Advanced Object-oriented Programming COMP 213 Advanced Object-oriented Programming Lecture 21 Concurrency What is Concurrency? Concurrency is when two or more programs execute at the same time, either: sharing the same processor (multi-threading),

More information

CSCD 330 Network Programming

CSCD 330 Network Programming CSCD 330 Network Programming Lecture 8 Client-Server Programming Threads Spring 2018 Reading: Chapter 2, Relevant Links - Threads Some Material in these slides from J.F Kurose and K.W. Ross All material

More information

Week 12. Streams and File I/O. Overview of Streams and File I/O Text File I/O

Week 12. Streams and File I/O. Overview of Streams and File I/O Text File I/O Week 12 Streams and File I/O Overview of Streams and File I/O Text File I/O 1 I/O Overview I/O = Input/Output In this context it is input to and output from programs Input can be from keyboard or a file

More information

Topics to be covered

Topics to be covered UNIT - II Topics to be covered Arrays Strings Packages Java-Doc comments Inheritance Class hierarchy Polymorphism Dynamic Binding final keyword abstract classes Arrays Arrays: An array is a collection

More information

we dont take any liability for the notes correctness.

we dont take any liability for the notes correctness. 1 Unit 3 Topic:Multithreading and Exception Handling Unit 3/Lecture 1 MultiThreading [RGPV/June 2011(10)] Unlike many other computer languages, Java provides built-in support for multithreaded programming.

More information

CSCD 330 Network Programming

CSCD 330 Network Programming CSCD 330 Network Programming Lecture 8 Client-Server Programming Threads Spring 2017 Reading: Chapter 2, Relevant Links - Threads Some Material in these slides from J.F Kurose and K.W. Ross All material

More information

Lab 11. A sample of the class is:

Lab 11. A sample of the class is: Lab 11 Lesson 11-2: Exercise 1 Exercise 2 A sample of the class is: public class List // Methods public void store(int item) values[length] = item; length++; public void printlist() // Post: If the list

More information

Software Practice 1 - Socket

Software Practice 1 - Socket Software Practice 1 - Socket Terms of socket programming Socket Implementation (TCP, UDP) Socket with multithread Serialization Lab practice Prof. Joonwon Lee T.A. Jaehyun Song Jongseok Kim T.A. Sujin

More information

Byte and Character Streams. Reading and Writing Console input and output

Byte and Character Streams. Reading and Writing Console input and output Byte and Character Streams Reading and Writing Console input and output 1 I/O basics The io package supports Java s basic I/O (input/output) Java does provide strong, flexible support for I/O as it relates

More information

9/23/2014. Concurrent Programming. Book. Process. Exchange of data between threads/processes. Between Process. Thread.

9/23/2014. Concurrent Programming. Book. Process. Exchange of data between threads/processes. Between Process. Thread. Dr A Sahu Dept of Computer Science & Engineering IIT Guwahati Course Structure & Book Basic of thread and process Coordination and synchronization Example of Parallel Programming Shared memory : C/C++

More information

SOURCE CODE. //Socket Programming using TCP Sockets. Server.java

SOURCE CODE. //Socket Programming using TCP Sockets. Server.java SOURCE CODE //Socket Programming using TCP Sockets Server.java import java.io.*; import java.net.*; public class Server public static void main (String args[]) throws Exception ServerSocket sersock=new

More information

Network. Dr. Jens Bennedsen, Aarhus University, School of Engineering Aarhus, Denmark

Network. Dr. Jens Bennedsen, Aarhus University, School of Engineering Aarhus, Denmark Network Dr. Jens Bennedsen, Aarhus University, School of Engineering Aarhus, Denmark jbb@ase.au.dk Outline Socket programming If we have the time: Remote method invocation (RMI) 2 Socket Programming Sockets

More information

Chapter 10 Input Output Streams

Chapter 10 Input Output Streams Chapter 10 Input Output Streams ICT Academy of Tamil Nadu ELCOT Complex, 2-7 Developed Plots, Industrial Estate, Perungudi, Chennai 600 096. Website : www.ictact.in, Email : contact@ictact.in, Phone :

More information

CS/B.TECH/CSE(New)/SEM-5/CS-504D/ OBJECT ORIENTED PROGRAMMING. Time Allotted : 3 Hours Full Marks : 70 GROUP A. (Multiple Choice Type Question)

CS/B.TECH/CSE(New)/SEM-5/CS-504D/ OBJECT ORIENTED PROGRAMMING. Time Allotted : 3 Hours Full Marks : 70 GROUP A. (Multiple Choice Type Question) CS/B.TECH/CSE(New)/SEM-5/CS-504D/2013-14 2013 OBJECT ORIENTED PROGRAMMING Time Allotted : 3 Hours Full Marks : 70 The figures in the margin indicate full marks. Candidates are required to give their answers

More information

Program 20: //Design an Applet program to handle Mouse Events. import java.awt.*; import java.applet.*; import java.awt.event.*;

Program 20: //Design an Applet program to handle Mouse Events. import java.awt.*; import java.applet.*; import java.awt.event.*; Program 20: //Design an Applet program to handle Mouse Events. import java.awt.*; import java.applet.*; import java.awt.event.*; /* */ public

More information

Recursive Problem Solving

Recursive Problem Solving Recursive Problem Solving Objectives Students should: Be able to explain the concept of recursive definition. Be able to use recursion in Java to solve problems. 2 Recursive Problem Solving How to solve

More information

6O03 project report. Main points for the solution. Build a combination possibility tableau. Problem: Page 5, the prime number problem

6O03 project report. Main points for the solution. Build a combination possibility tableau. Problem: Page 5, the prime number problem 1 6O03 project report Problem: Page 5, the prime number problem Main points for the solution The problem is asking a minimum value of k with given a number of the possibility of its prime combination multinomial.

More information

Recitation: Loop Jul 7, 2008

Recitation: Loop Jul 7, 2008 Nested Loop Recitation: Loop Jul 7, 2008 1. What is the output of the following program? Use pen and paper only. The output is: ****** ***** **** *** ** * 2. Test this program in your computer 3. Use "for

More information

JAVA Programming Language Homework VI: Threads & I/O

JAVA Programming Language Homework VI: Threads & I/O JAVA Programming Language Homework VI: Threads & I/O ID: Name: 1. When comparing java.io.bufferedwriter to java.io.filewriter, which capability exists as a method in only one of the two? A. Closing the

More information

7. MULTITHREDED PROGRAMMING

7. MULTITHREDED PROGRAMMING 7. MULTITHREDED PROGRAMMING What is thread? A thread is a single sequential flow of control within a program. Thread is a path of the execution in a program. Muti-Threading: Executing more than one thread

More information

e) Implicit and Explicit Type Conversion Pg 328 j) Types of errors Pg 371

e) Implicit and Explicit Type Conversion Pg 328 j) Types of errors Pg 371 Class IX HY 2013 Revision Guidelines Page 1 Section A (Power Point) Q1.What is PowerPoint? How are PowerPoint files named? Q2. Describe the 4 different ways of creating a presentation? (2 lines each) Q3.

More information

Note: Each loop has 5 iterations in the ThreeLoopTest program.

Note: Each loop has 5 iterations in the ThreeLoopTest program. Lecture 23 Multithreading Introduction Multithreading is the ability to do multiple things at once with in the same application. It provides finer granularity of concurrency. A thread sometimes called

More information

What is a Thread? Individual and separate unit of execution that is part of a process. multiple threads can work together to accomplish a common goal

What is a Thread? Individual and separate unit of execution that is part of a process. multiple threads can work together to accomplish a common goal Java Threads What is a Thread? Individual and separate unit of execution that is part of a process multiple threads can work together to accomplish a common goal Video Game example one thread for graphics

More information

Good Earth School Naduveerapattu Date: Marks: 70

Good Earth School Naduveerapattu Date: Marks: 70 Good Earth School Naduveerapattu Date:.2.207 Marks: 70 Class: XI Second Term Examination Computer Science Answer Key Time: 3 hrs. Candidates are allowed additional 5 minutes for only reading the paper.

More information

CPSC 441 Tutorial TCP Server. Department of Computer Science University of Calgary

CPSC 441 Tutorial TCP Server. Department of Computer Science University of Calgary CPSC 441 Tutorial TCP Server Department of Computer Science University of Calgary TCP Socket Client Server Connection Request Server Listening on welcoming socket Client Socket Server Socket Data Simple

More information

//Title: EE/CIS 694T //Version: //Copyright: Copyright (c) 2000 //Author: Furrukh Khan //Company: OSU //Description: Final Solution

//Title: EE/CIS 694T //Version: //Copyright: Copyright (c) 2000 //Author: Furrukh Khan //Company: OSU //Description: Final Solution public class Experiment { public static void main(string[] args) { Tank maintank = new Tank(); maintank.setminvolume(10.0d); maintank.setmaxvolume(100.0d); maintank.setfullvolume(110.0d); ValveController

More information

Internet and Intranet Applications and Protocols Examples of Bad SMTP Code Prof. Arthur P. Goldberg Spring, 2004

Internet and Intranet Applications and Protocols Examples of Bad SMTP Code Prof. Arthur P. Goldberg Spring, 2004 Internet and Intranet Applications and Protocols Examples of Bad SMTP Code Prof. Arthur P. Goldberg Spring, 00 Summary I show some examples of bad code and discuss how they fail to meet the Software Quality

More information

Process management. Desarrollo de Aplicaciones en Red. Process in memory. Concepts. Process state diagram. Process state

Process management. Desarrollo de Aplicaciones en Red. Process in memory. Concepts. Process state diagram. Process state Process management Desarrollo de Aplicaciones en Red José Rafael Rojano Cáceres http://www.uv.mx/rrojano A process can be thought as a program in execution. Process are the unit of work on modern time-sharing

More information

Multithreading using Java. Dr. Ferdin Joe John Joseph

Multithreading using Java. Dr. Ferdin Joe John Joseph Multithreading using Java Dr. Ferdin Joe John Joseph 1 Agenda Introduction Thread Applications Defining Threads Java Threads and States Priorities Accessing Shared Resources Synchronisation Assignment

More information

Multithreaded Programming

Multithreaded Programming Multithreaded Programming 1 Java provides built-in support for multithreaded programming. A multithreaded program contains two or more parts that can run concurrently. Each part of such a program is called

More information

INFO Ass 4. Exercise 1

INFO Ass 4. Exercise 1 Exercise 1 INFO 408 - Ass 4 public class UserInfo public static final long TIME_OUT = 1000 * 3000 ; public String user; public long id; public long creationdate; public UserInfo(String user,long id) this.user

More information

Distributed Systems COMP 212. Lecture 8 Othon Michail

Distributed Systems COMP 212. Lecture 8 Othon Michail Distributed Systems COMP 212 Lecture 8 Othon Michail HTTP Protocol Hypertext Transfer Protocol Used to transmit resources on the WWW HTML files, image files, query results, Identified by Uniform Resource

More information

Homework 3 Huffman Coding. Due Thursday October 11

Homework 3 Huffman Coding. Due Thursday October 11 Homework 3 Huffman Coding Due Thursday October 11 Huffman Coding Implement Huffman Encoding and Decoding and the classes shown on the following slides. You will also need to use Java s stack class HuffmanEncode

More information

Introduction to Sockets

Introduction to Sockets Introduction to Sockets Sockets in Java 07/02/2012 EPL 602 1 Socket programming Goal: learn how to build client/server application that communicate using sockets Socket API o introduced in BSD4.1 UNIX,

More information

M257 Past Paper Oct 2007 Attempted Solution

M257 Past Paper Oct 2007 Attempted Solution M257 Past Paper Oct 2007 Attempted Solution Part 1 Question 1 The compilation process translates the source code of a Java program into bytecode, which is an intermediate language. The Java interpreter

More information

Java for Interfaces and Networks

Java for Interfaces and Networks Java for Interfaces and Networks Threads and Networking Federico Pecora School of Science and Technology Örebro University federico.pecora@oru.se Federico Pecora Java for Interfaces and Networks Lecture

More information

URL Kullanımı Get URL

URL Kullanımı Get URL Networking 1 URL Kullanımı Get URL URL info 2 import java.io.*; import java.net.*; public class GetURL { public static void main(string[] args) { InputStream in = null; OutputStream out = null; // Check

More information

Instance Method Development Demo

Instance Method Development Demo Instance Method Development Demo Write a class Person with a constructor that accepts a name and an age as its argument. These values should be stored in the private attributes name and age. Then, write

More information

CSCD 330 Network Programming Spring 2018

CSCD 330 Network Programming Spring 2018 CSCD 330 Network Programming Spring 2018 Lecture 6 Application Layer Socket Programming in Java Reading for Java Client/Server see Relevant Links Some Material in these slides from J.F Kurose and K.W.

More information

Midterm assessment - MAKEUP Fall 2010

Midterm assessment - MAKEUP Fall 2010 M257 MTA Faculty of Computer Studies Information Technology and Computing Date: /1/2011 Duration: 60 minutes 1-Version 1 M 257: Putting Java to Work Midterm assessment - MAKEUP Fall 2010 Student Name:

More information

WINDOWS SOCKET PROGRAMMING

WINDOWS SOCKET PROGRAMMING WINDOWS SOCKET PROGRAMMING Headers and libraries All the declarations are in one header, winsock.h Your socket programs must link to the Winsock library (usually called wsock32.lib or winsock32.lib) Initialization

More information