Showing posts from June, 2021Show all

10) Write a Java program that finds average marks of two subjects also display student name and marks using constructor instance variable.

source file name:  MarksDemo.java   class Marks { int sub1 , sub2; public Marks(int s1, int s2) // definition constructor { sub1=s1; sub2=s2; } } class Marks1 { String name; Marks m; public Marks1(String nm,int s1, int s2) // definition constructor { m=new Marks(s1,s2); name=nm; } public void display() { System.out.pr…

Read more

3) Write a Java program that client sends message to Server.

source file name: MyServer.java   import java.io.*;   import java.net.*;   public class MyServer  {   public static void main(String[] args) {   try {   ServerSocket ss=new ServerSocket(6666);   Socket s=ss.accept();//establishes connection    DataInputStream dis=new DataInputStream(s.getInputStream());   String  str…

Read more

4) Write a Java program that Server sends message to client.

source file name: Server1.java   import java.io.*;   import java.net.*;   public class Server1  {   public static void main(String[] args) {   try {   ServerSocket ss=new ServerSocket(1111);   Socket s=ss.accept();//establishes connection    DataOutputStream dout=new DataOutputStream(s.getOutputStream());   System.out…

Read more