0% found this document useful (0 votes)
2 views1 page

Java 20programs CheatSheet

Uploaded by

25bca107
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views1 page

Java 20programs CheatSheet

Uploaded by

25bca107
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

JAVA LAB CHEAT (SHORT FORM)

P1 main(){syso([Link]...[Link]);}
P2 int g=10; static int s=20; void d(){int l=40;} main(){obj.d();}
P3 main(){[Link](); str1+str2; [Link](0,6);}
P4 main(){if(a>b&&a;>c)m=a; else if(b>c)m=b; else m=c;}
P5 main(){if(n%2==0) syso("Even"); else syso("Odd");}
P6 class Car{Car(){} Car(String b,String m,int y){}}
P7 Student s[]={new Student(...),new Student(...)}; for(Student x:s)[Link]();
P8 class Manager extends Employee{}
P9 interface A{} interface B{} class C implements A,B{}
P11 try{a/0;}catch(ArithmeticException e){}
P12 int add(int a,int b){} int add(){} float add(float a,float b){}
P13 Payment p=new CreditCardPayment(); [Link](); p=new UpiPayment();
P14 try{int a[]=new int[-5];}catch(NegativeArraySizeException e){}
P15 try{String s=null; [Link]();}catch(NullPointerException e){}finally{}
P16 package mypackage; class Greeting{} import [Link];
P17 org=n; while(n!=0){r=n%10; rev=rev*10+r; n/=10;} if(org==rev)
P18 fact=1; for(i=1;i<=n;i++) fact*=i;
P19 isPrime(n){for(i=2;i<=sqrt(n);i++) if(n%i==0)return false;}
P20 class MyRunnable implements Runnable{public void run(){}} Thread t=new Thread(obj); [Link]();
Keywords: Constructor=Init Object | Inheritance=extends | Interface=implements | Overloading=same method diff args | Overriding=runtime poly | Exception=try-catch | Thread=start()

You might also like