Posts

Quantum Internet Benefits

Image
  The quantum internet is a network of quantum computers that are connected together using quantum communication. It has the potential to revolutionize many industries, including: Secure communications: The quantum internet would be inherently secure, as it would be impossible to eavesdrop on quantum communications without being detected. This could be used for applications such as secure financial transactions, government communications, and military applications. Quantum computing: The quantum internet would allow quantum computers to be connected together, which would allow them to solve problems that are currently impossible for classical computers. This could be used for applications such as drug discovery, financial modeling, artificial intelligence, and materials science. Quantum sensors: The quantum internet could be used to connect quantum sensors together, which would allow them to create a global network of sensors that could be used to monitor the environment, detect earthq

Java Program: Up casting Program in inheritance

Image
Program public class upcasting {    public static void main(String[] args)     {      car c,cc,ccc,o;      o=new car();      o.car(); //no casting      c=(car)new ford(); //upcasting ford sub class to super class      c.car();      cc=(car)new benz();//upcasting ford sub class to super class      cc.car();      ccc=(car)new BMW();//upcasting ford sub class to super class            ccc.car();         } } class car {     void car()     {         System.out.println("This super class car method");     } } class ford extends car {     @Override     void car()     {         System.out.println("This sub class Ford car method");     } } class benz extends car {      @Override     void car()     {         System.out.println("This sub class Benz car method");     } } class BMW extends car {      @Override     void car()     {         System.out.println("This sub class BMW car method");     } } Output

Java Program: Inheritance Super Keyword

Image
Program class inheritance {  public static void main(String[] args)  {   apple a=new apple();   a.disp();  } } class fruit {  String f="fruit";  public void disp()  {   System.out.println("Base Class "+f);  } } class apple extends fruit {  String f="Apple";  public void disp()  {   System.out.println("Derived Class  "+f);   super.disp();   System.out.println("Super Class "+super.f);  } } Output

Java Program: File I/O Fileoutputstream to create file

Image
Program import java.io.*; public class createfile {     public static void main(String[] args)     {         try         {         createfile();         }         catch(Exception ex)         {             System.out.println("File Exceptio occured");         }         }     public static void createfile() throws java.io.IOException     {         DataInputStream d=new DataInputStream(System.in);         FileOutputStream f=new FileOutputStream("jack.txt",true);         BufferedOutputStream b=new BufferedOutputStream(f,1024);         System.out.println("Enter $ at the end to finish text");         char c;         while((c=(char)d.read())!='$')         {             b.write(c);                   }         b.close();     } } Output

Java Program: AWT Frame Closing Event

Image
Program import java.awt.*; import java.awt.event.*; public class awtexample extends Frame{     public static void main(String[] args)     {         Frame f= new Frame("New Frame");         f.setSize(400, 500);         f.setVisible(true);         f.addWindowListener(new WindowAdapter(){         public void windowClosing(WindowEvent e)         {         System.exit(0);         }      });     } } Output

Java Program: Multi Thread optimum way utilize CPU time using Thread(Runnable object, String thread_name)

Program i mport java.util.logging.Level; import java.util.logging.Logger; class ThreadRunnnable {     public static void main(String[] args)     {                new ThreadRun();        new ThreadRunn();        System.out.println("Main Thread Starts");         for(int i=1;i<=5;i++)         {             System.out.println(i);             try {                 Thread.sleep(1500);             } catch (InterruptedException ex) {                 Logger.getLogger(ThreadRun.class.getName()).log(Level.SEVERE, null, ex);             }         }                         } } class ThreadRun implements Runnable {     ThreadRun()     {                 Thread t=new Thread(this,"Thread1");         t.start();         System.out.println("Thread 1");             }     @Override     public void run()     {         for(int i=1;i<=5;i++)         {             System.out.println(i);             try {                 Thread.sleep(5