Skip to main content

Posts

Showing posts from November 11, 2013

Linux Terminal Commands

Install Command sudo apt-get install <package-name> Example: Installing vlc media player sudo apt-get install vlc ls Command ls -l list folders and files with read write permissions and user groups ls -a This command shows hidden files and folders ls -al ls -la Clear Command clear this command clears the screen Manual Command man <command> this command shows manual of the commands example man ls shows manual command of ls q to quit the manual screen back to terminal commands ifconfig command ifconfig command ip network address details netstat command netstat command used to show network status like ip addresses of local and foreign; port, pid, network protocols cat Command   cat  command  concatenate files and print on the standard output.

Java Program: Down casting Inheritence

Program public class downcasting {    public static void main(String[] args)     {      fordd f;      benzz b;      BMWw bm;      carr c,cc,ccc;      c=new fordd();      cc=new benzz();      ccc=new BMWw();      f=(fordd)c; // downcasting or narrowing or specialization      b=(benzz)cc;      bm=(BMWw)ccc;      f.car();      b.car();      bm.car();     } } class carr {     void car()     {         System.out.println("This super class car method");     } } class fordd extends carr {     void car()     {         System.out.println("This sub class Ford car method");     } } class benzz extends carr {      void car() ...

Java Program: Up casting Program in inheritance

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 { ...

Java Program: Inheritance Super Keyword

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

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=(c...

Java Program: AWT Frame Closing Event

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