├── .gitignore ├── Prog55.java ├── test ├── Mathops.java └── Customer.java ├── Prog05.java ├── Prog53.java ├── Prog06.java ├── Prog66.java ├── Prog02.java ├── Prog16.java ├── Prog20.java ├── Tips_Tricks ├── Trick02.java └── Trick01.java ├── MathUtil.java ├── Prog07.java ├── Prog59.java ├── Prog68.java ├── Prog69.java ├── Prog30.java ├── Prog84.java ├── Prog35.java ├── Prog54.java ├── Prog14.java ├── Prog73.java ├── Prog01.java ├── Prog03.java ├── Prog44.java ├── dummytext.txt ├── Prog43.java ├── Prog71.java ├── Prog08.java ├── Prog74.java ├── Prog15.java ├── Prog10.java ├── Prog60.java ├── Prog33.java ├── Prog29.java ├── Prog17.java ├── Prog42.java ├── Prog13.java ├── Prog12.java ├── Prog31.java ├── Prog22.java ├── Prog39.java ├── Prog27.java ├── Prog09.java ├── Prog62.java ├── Prog67.java ├── Prog34.java ├── Prog23.java ├── Prog70.java ├── Prog11.java ├── Prog19.java ├── Prog18.java ├── Prog21.java ├── Prog47.java ├── Prog78.java ├── Prog77.java ├── Prog25.java ├── Prog63.java ├── Prog24.java ├── Prog36.java ├── Prog61.java ├── Prog79.java ├── Prog40.java ├── Prog75.java ├── Prog82.java ├── Prog49.java ├── Prog45.java ├── Prog46.java ├── Prog51.java ├── Prog72.java ├── Prog80.java ├── Prog38.java ├── Prog50.java ├── Prog56.java ├── Prog89.java ├── Prog41.java ├── Prog37.java ├── Prog81.java ├── Prog57.java ├── Prog83.java ├── Prog85.java ├── Prog88.java ├── Prog28.java ├── Prog26.java ├── Prog64.java ├── Prog32.java ├── Prog98.java ├── Prog58.java ├── Prog86.java ├── Prog90.java ├── Prog96.java ├── Prog91.java ├── Prog76.java ├── Prog95.java ├── Parent_Frame.java ├── Prog93.java ├── Prog97.java ├── Prog92.java ├── Prog65.java ├── Prog52.java ├── Prog94.java ├── Prog48.java ├── README.md └── a /.gitignore: -------------------------------------------------------------------------------- 1 | *.class 2 | -------------------------------------------------------------------------------- /Prog55.java: -------------------------------------------------------------------------------- 1 | //an example on final class 2 | final class A 3 | { 4 | 5 | } 6 | class B extends A 7 | { 8 | //cannot inherit from final A 9 | } -------------------------------------------------------------------------------- /test/Mathops.java: -------------------------------------------------------------------------------- 1 | //to access a class kept in a package 2 | 3 | package test; 4 | public class Mathops 5 | { 6 | public static int abs(int x) 7 | { 8 | if(x<0) 9 | return -x; 10 | return x; 11 | } 12 | } -------------------------------------------------------------------------------- /Prog05.java: -------------------------------------------------------------------------------- 1 | // example on increment operator 2 | class Prog05 3 | { 4 | public static void main(String[] args) 5 | { 6 | //print hello 5 times 7 | for(int i=0;i<5;i++) 8 | System.out.println("hello"); 9 | 10 | } 11 | } -------------------------------------------------------------------------------- /Prog53.java: -------------------------------------------------------------------------------- 1 | //an example of final keyword with variable 2 | class Prog53 3 | { 4 | public static void main(String[] args) 5 | { 6 | final double PI = 3.14; 7 | //PI = 3.14144; //cannot assign a value to final variable 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /Prog06.java: -------------------------------------------------------------------------------- 1 | // example on literal 2 | class Prog06 3 | { 4 | public static void main(String[] args) 5 | { 6 | char ch = 'a'; 7 | ch++; 8 | System.out.println("ch contains "+ch); 9 | System.out.println("unicode of ch is "+(int)ch); 10 | } 11 | } -------------------------------------------------------------------------------- /Prog66.java: -------------------------------------------------------------------------------- 1 | import test.Mathops; 2 | 3 | public class Prog66 4 | { 5 | public static void main(String[] args) 6 | { 7 | int num = Integer.parseInt(args[0]); 8 | num = Mathops.abs(num); 9 | System.out.println("Absolute value of numbers is "+num); 10 | } 11 | } -------------------------------------------------------------------------------- /Prog02.java: -------------------------------------------------------------------------------- 1 | // write a program to display contents of variables 2 | class Prog02 3 | { 4 | public static void main(String[] args) 5 | { 6 | int a = 10; 7 | int b = a*10; 8 | System.out.println("a contains "+a); 9 | System.out.println("b contains "+b); 10 | } 11 | } -------------------------------------------------------------------------------- /Prog16.java: -------------------------------------------------------------------------------- 1 | //example on self initialized 1D array 2 | class Prog16 3 | { 4 | 5 | public static void main(String[] args) 6 | { 7 | int[] nos = {1,2,3,4,5}; 8 | System.out.println("nos[] are "); 9 | 10 | for(int i=0;i<5;i++) 11 | System.out.print(nos[i]+"\t"); 12 | } 13 | } -------------------------------------------------------------------------------- /Prog20.java: -------------------------------------------------------------------------------- 1 | //accept different numbers from user a a commandline arg and display their sum 2 | class Prog20 3 | { 4 | public static void main(String[] args) 5 | { 6 | double sum = 0; 7 | for(int i=0;ijdk 1.7) 13 | It is possible to assign numeric literals with unerscore 14 | */ -------------------------------------------------------------------------------- /MathUtil.java: -------------------------------------------------------------------------------- 1 | class MathUtil 2 | { 3 | static boolean isPrime(int x) 4 | { 5 | for(int i=2;i0) 14 | { 15 | sum+=x%10; 16 | x/=10; 17 | } 18 | return sum; 19 | } 20 | } -------------------------------------------------------------------------------- /Prog07.java: -------------------------------------------------------------------------------- 1 | //example on boolean literal 2 | class Prog07 3 | { 4 | public static void main(String[] args) 5 | { 6 | //to print 'hello' 5 times 7 | boolean b = true; 8 | int cntr = 0; 9 | while(b) 10 | { 11 | System.out.println("Hello"); 12 | cntr++; 13 | if(cntr==5) 14 | b=false; 15 | } 16 | } 17 | } -------------------------------------------------------------------------------- /Prog59.java: -------------------------------------------------------------------------------- 1 | //an example of uncaught exception 2 | class Prog59 3 | { 4 | public static void main(String[] args) 5 | { 6 | int num=10,denom=0; 7 | int result = num/denom; 8 | System.out.println("Result of operation is "+result); 9 | //Exception in thread "main" java.lang.ArithmeticException: / by zero 10 | } 11 | } -------------------------------------------------------------------------------- /Prog68.java: -------------------------------------------------------------------------------- 1 | //g1 on String class constructor 2 | 3 | class Prog68 4 | { 5 | public static void main(String[] args) 6 | { 7 | char arr[]={'d','a','t','a','b','y','t','e'}; 8 | String s1 = new String(arr); 9 | String s2 = new String(arr,2,3); 10 | 11 | System.out.println("S1 contains "+s1); 12 | System.out.println("S2 contains "+s2); 13 | 14 | } 15 | } -------------------------------------------------------------------------------- /Prog69.java: -------------------------------------------------------------------------------- 1 | //eg2 on String class constructor 2 | 3 | 4 | 5 | class Prog69 6 | { 7 | public static void main(String[] args) 8 | { 9 | byte arr[]={65,66,67,68,69,70}; 10 | String s1 = new String(arr); 11 | String s2 = new String(arr,2,3); 12 | 13 | System.out.println("S1 contains "+s1); 14 | System.out.println("S2 contains "+s2); 15 | 16 | } 17 | } -------------------------------------------------------------------------------- /Prog30.java: -------------------------------------------------------------------------------- 1 | //an eg on parameterized constructor 2 | class Pconstructor 3 | { 4 | Pconstructor(int x) 5 | { 6 | System.out.println("Inside the default constructor of clas Pconstructor"); 7 | System.out.println("x="+x); 8 | } 9 | } 10 | class Prog30 11 | { 12 | public static void main(String[] args) 13 | { 14 | Pconstructor p1 = new Pconstructor(10); 15 | } 16 | } -------------------------------------------------------------------------------- /Tips_Tricks/Trick01.java: -------------------------------------------------------------------------------- 1 | //tricks in java 2 | //comments can be excuted too 3 | class Trick01 4 | { 5 | public static void main(String[] args) 6 | { 7 | // \u000d System.out.println("Welcome to Databyte Coaching Classes"); 8 | } 9 | } 10 | /*This line of code will always execute because of Unicode 11 | "\u000d" and java compiler parses this unicode character as newLine 12 | */ -------------------------------------------------------------------------------- /Prog84.java: -------------------------------------------------------------------------------- 1 | //write a program in java to determine presene of stop word in string 2 | 3 | class Prog84 4 | { 5 | public static void main(String[] args) 6 | { 7 | String line = "Please don't stop"; 8 | 9 | int pos = line.indexOf("stop"); 10 | 11 | if(pos!=-1) 12 | System.out.println("Stop present"); 13 | 14 | else 15 | System.out.println("Stop not present"); 16 | } 17 | } -------------------------------------------------------------------------------- /Prog35.java: -------------------------------------------------------------------------------- 1 | //with only 1 SOP("Hello") in main() WAP to get following output 2 | //Hi 3 | //Hello 4 | //Bye 5 | 6 | class Prog35 7 | { 8 | static 9 | { 10 | System.out.println("Hi"); 11 | main(null); 12 | System.out.println("Bye"); 13 | System.exit(0); //avoid the auto call to main() 14 | } 15 | public static void main(String[] args) 16 | { 17 | System.out.println("Hello"); 18 | } 19 | } -------------------------------------------------------------------------------- /Prog54.java: -------------------------------------------------------------------------------- 1 | //an eg on final method 2 | class A 3 | { 4 | final void meth() 5 | { 6 | System.out.println("A's implementation of meth()"); 7 | } 8 | } 9 | class B extends A 10 | { 11 | void meth() 12 | { 13 | /*meth() in B cannot override meth() in A 14 | void meth() 15 | ^ 16 | overridden method is final*/ 17 | System.out.println("A's implementation of meth()"); 18 | } 19 | } -------------------------------------------------------------------------------- /Prog14.java: -------------------------------------------------------------------------------- 1 | //example1 scope 2 | class Prog14 3 | { 4 | //global scope 5 | public static void main(String[] args) 6 | { 7 | //outer scope 8 | int out_x=10; 9 | 10 | //inner scope 11 | { 12 | int in_x=20; 13 | //int out_x=30; //error, out_x is a;redy defined 14 | 15 | System.out.println("in_x contains "+in_x); 16 | System.out.println("out_x contains "+out_x); 17 | } 18 | 19 | } 20 | } -------------------------------------------------------------------------------- /Prog73.java: -------------------------------------------------------------------------------- 1 | //example of split method to convert String into array of Strings 2 | class Prog73 3 | { 4 | public static void main(String[] args) 5 | { 6 | String name="databyte computer coaching classes"; 7 | String arr[] = name.split(" "); 8 | //delimeter in space 9 | System.out.println("Elements of array are :- "); 10 | for(int i=0;i string.length 11 | //becomes string.length 12 | 13 | System.out.println("s1 contains "+s1); 14 | System.out.println("s2 contains "+s2); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /Prog15.java: -------------------------------------------------------------------------------- 1 | //example1 scope 2 | class Prog15 3 | { 4 | 5 | public static void main(String[] args) 6 | { 7 | //to print "hello" 5 times 8 | //in t cntr; //preferred if you wish t use this 9 | //var for multiple loops 10 | 11 | //if declared in loop,we are limiting its scope to the loop 12 | for(int cntr=0;cntr<5;class++) 13 | System.out.println("hello"); 14 | 15 | 16 | //to print hi 6 times 17 | for(cntr=0;cntr<6;cntr++) 18 | System.out.println("hi"); 19 | } 20 | } -------------------------------------------------------------------------------- /Prog10.java: -------------------------------------------------------------------------------- 1 | //example on double literal literal 2 | class Prog10 3 | { 4 | public static void main(String[] args) 5 | { 6 | float f1 = 9;//ok 7 | //float f2 = 9.0;//compiler error, possible loss of precision 8 | //required float ,found double 9 | float f2 = 9.0F;//ok 10 | double d = 123.1234567890123;//ok 11 | 12 | System.out.println("f1 contains "+f1); //9.0 13 | System.out.println("f2 contains "+f2); //9.0 14 | System.out.println("d contains "+d); //same as assigned 15 | } 16 | } -------------------------------------------------------------------------------- /Prog60.java: -------------------------------------------------------------------------------- 1 | //an example of caught exception 2 | class Prog60 3 | { 4 | public static void main(String[] args) 5 | { 6 | try 7 | { 8 | int num=10,denom=0; 9 | int result = num/denom; 10 | System.out.println("Result of operation is "+result); 11 | 12 | } 13 | catch(ArithmeticException e) 14 | { 15 | System.out.println("Division by zero is rulred out"); 16 | return ; 17 | } 18 | finally 19 | { 20 | System.out.println("This is the code in finally{}"); 21 | } 22 | } 23 | } -------------------------------------------------------------------------------- /Prog33.java: -------------------------------------------------------------------------------- 1 | //an example on static variables 2 | 3 | //define a mthod to accept n numbers and display its sum 4 | 5 | class Prog33 6 | { 7 | //instance member 8 | int num1 = 10; 9 | int num2 = num1*2; 10 | public static void main(String[] args) 11 | { 12 | //solution 1 declare vars in main() 13 | //solution 2 //declare vars as static 14 | //solution 3 use instance 15 | 16 | Prog33 obj = new Prog33(); 17 | System.out.println("num1 ="+obj.num1); 18 | System.out.println("num2 ="+obj.num2); 19 | } 20 | } -------------------------------------------------------------------------------- /Prog29.java: -------------------------------------------------------------------------------- 1 | //an eg on default constructor 2 | class Dconstructor 3 | { 4 | Dconstructor() 5 | { 6 | System.out.println("Inside the default constructor of clas Dconstructor"); 7 | } 8 | } 9 | class Prog29 10 | { 11 | public static void main(String[] args) 12 | { 13 | Dconstructor d1 = new Dconstructor(); //declaration and memory allocation , 14 | //invokes constructor implicitly 15 | 16 | Dconstructor d2;//constructor not called 17 | //d1.Dconstructor(); //cannot invoke constructor explicitly 18 | } 19 | } -------------------------------------------------------------------------------- /Prog17.java: -------------------------------------------------------------------------------- 1 | //example on 2*2 display of a matrix 2 | class Prog17 3 | { 4 | public static void main(String[] args) 5 | { 6 | int[][] a = {{10,20},{30,40}},b={{50,60},{70,80}}; 7 | 8 | int[][] t= new int[2][2]; 9 | int r,c; 10 | 11 | for(r=0;r<2;r++) 12 | { 13 | for(c=0;c<2;c++) 14 | { 15 | t[r][c]=a[r][c]+b[r][c]; 16 | } 17 | } 18 | 19 | for(r=0;r<2;r++) 20 | { 21 | for(c=0;c<2;c++) 22 | { 23 | System.out.print(t[r][c]+"\t"); 24 | } 25 | System.out.println(); 26 | } 27 | } 28 | } -------------------------------------------------------------------------------- /Prog42.java: -------------------------------------------------------------------------------- 1 | //an example on hidden member of superclass 2 | class A 3 | { 4 | int i; 5 | } 6 | class B extends A 7 | { 8 | int i; //ok but hides "i " of superclass 9 | B(int x,int y) 10 | { 11 | i=x;//will initiate "i" of B to x 12 | super.i=y; //will initiate "i" of A to y 13 | } 14 | void display() 15 | { 16 | System.out.println("B's i "+i+" A's i "+super.i); 17 | } 18 | } 19 | 20 | 21 | class Prog42 22 | { 23 | public static void main(String[] args) 24 | { 25 | B b = new B(10,20); 26 | b.display(); 27 | } 28 | } -------------------------------------------------------------------------------- /Prog13.java: -------------------------------------------------------------------------------- 1 | //example2 on type promotion in expression 2 | class Prog13 3 | { 4 | public static void main(String[] args) 5 | { 6 | int r=10; 7 | 8 | //float cc = 3.14*2*r;//error,possible loss of precision found double , reqd float 9 | //float ac = 3.14*r*r;//error,same as above 10 | 11 | //when two float numbers are multiplied they become double 12 | 13 | double cc = 3.14*r*2;//ok 14 | float ac = 3.14F*r*r;//ok 15 | 16 | System.out.println("ac contains "+ac); 17 | System.out.println("cc contains "+cc); 18 | } 19 | } -------------------------------------------------------------------------------- /Prog12.java: -------------------------------------------------------------------------------- 1 | //example on type promotion in expression 2 | class Prog12 3 | { 4 | public static void main(String[] args) 5 | { 6 | byte a=2,b=5,c; 7 | //when two bytes or shorts are added,subtracted they become integer 8 | //c = a-b; //error, possoble loss of precision found int,required float 9 | c=(byte)(a+b); 10 | System.out.println("c contains "+c); 11 | 12 | char ch = 'a'; 13 | ch++; //ok 14 | //ch=ch+1; //error,possible loss of precision,found int reqd char 15 | 16 | System.out.println("ch contains "+ch);//b 17 | } 18 | } -------------------------------------------------------------------------------- /Prog31.java: -------------------------------------------------------------------------------- 1 | //an example on this keyword 2 | class Point 3 | { 4 | private int x,y; 5 | private String colour; 6 | 7 | public Point(int x,int y,String colour) 8 | { 9 | this.x=x; 10 | this.y=y; 11 | this.colour=colour; 12 | } 13 | public void display() 14 | { 15 | System.out.println("Co-ordinates of point are x="+x+" y="+y); 16 | System.out.println("Colour of the point is "+colour); 17 | } 18 | } 19 | class Prog31 20 | { 21 | public static void main(String[] args) 22 | { 23 | Point p = new Point(10,20,"black"); 24 | p.display(); 25 | } 26 | } -------------------------------------------------------------------------------- /Prog22.java: -------------------------------------------------------------------------------- 1 | //accept a character from user and change its case 2 | 3 | class Prog22 4 | { 5 | public static void main(String[] args) 6 | { 7 | char ch = args[0].charAt(0); 8 | 9 | //no such method called Character.parseChar() ; 10 | 11 | if(!Character.isLetter(ch)) 12 | System.out.println(" Please enter letters only"); 13 | 14 | 15 | else 16 | { 17 | if(Character.isLowerCase(ch)) 18 | ch = Character.toUpperCase(ch); 19 | else 20 | ch = Character.toLowerCase(ch); 21 | 22 | System.out.println("character now is "+ch); 23 | } 24 | } 25 | } -------------------------------------------------------------------------------- /Prog39.java: -------------------------------------------------------------------------------- 1 | //define a mthod to accept n numbers and display its sum 2 | 3 | class Prog39 4 | { 5 | static int test(int ...nos) 6 | { 7 | int sum = 0; 8 | for(int i=0;i0) 11 | return no; 12 | else 13 | return -no; 14 | } 15 | public static void main(String[] args) 16 | { 17 | int no = Integer.parseInt(args[0]); 18 | 19 | no = Prog23.abs(no); 20 | // no = abs(no); //valid , as both the methods are from same class 21 | System.out.println("absolute of given no. is " +no ); 22 | } 23 | } -------------------------------------------------------------------------------- /Prog70.java: -------------------------------------------------------------------------------- 1 | /* To prove that new Strings are not created always Especially when they 2 | are created using a string literal*/ 3 | 4 | class Prog70 5 | { 6 | public static void main(String[] args) 7 | { 8 | String s1 = "databyte"; 9 | String s2 = new String("databyte"); 10 | String s3 = "databyte"; 11 | 12 | System.out.println("Are contents of s1 and s2 same? "+s1.equals(s2)); 13 | System.out.println("Are contents of s1 and s3 same? "+s1.equals(s3)); 14 | 15 | System.out.println("Are references of of s1 and s2 same? "+(s1==s2)); 16 | System.out.println("Are references of s1 and s3 same? "+(s1==s3)); 17 | } 18 | } -------------------------------------------------------------------------------- /Prog11.java: -------------------------------------------------------------------------------- 1 | //an example on explicit conversion 2 | 3 | class Prog11 4 | { 5 | public static void main(String[] args) 6 | { 7 | byte b1 = 100;//ok 8 | int i = 100;//ok 9 | //byte b2 = i; //compiler error, 10 | //possible lack of precision 11 | byte b2 = (byte)i;//ok 12 | //byte b3 = 130;//error,same as above 13 | byte b3 = (byte)130;//ok 14 | byte b4 = (byte)300;//ok 15 | //if no>256 no=no%256 16 | 17 | System.out.println("b1 contains "+b1); //100 18 | System.out.println("b2 contains "+b2); //100 19 | System.out.println("b3 contains "+b3); //-126 20 | System.out.println("b4 contains "+b4); //44 21 | } 22 | } -------------------------------------------------------------------------------- /Prog19.java: -------------------------------------------------------------------------------- 1 | //aaccept a year from user as a command line argument 2 | //and determine whether it is leap yr or not 3 | 4 | class Prog19 5 | { 6 | public static void main(String[] args) 7 | { 8 | //int yr = (int)args[0]; //error,inconvertible types,reqd int found String 9 | //typecasting is applicable only to the primitive data types 10 | 11 | int yr = Integer.parseInt(args[0]); 12 | //this conversion requires to call a special method called parseInt() from Integer class 13 | if(yr%4==0 && yr%100!=0) 14 | System.out.println(yr+" is a leap year"); 15 | else 16 | System.out.println(yr+" is a not a leap year"); 17 | } 18 | } -------------------------------------------------------------------------------- /Prog18.java: -------------------------------------------------------------------------------- 1 | //an examlpe on jagged array 2 | //example on 2*2 display of a matrix 3 | class Prog18 4 | { 5 | public static void main(String[] args) 6 | { 7 | int[][] sal = new int[3][]; //number of colums are not compulsory 8 | sal[0]=new int[2]; 9 | sal[1]=new int[5]; 10 | sal[2]=new int[3]; 11 | 12 | int key=10,i,j; 13 | for(i=0;i<3;i++) 14 | { 15 | for(j=0;j"+num); 15 | cntr++; 16 | } 17 | catch(NumberFormatException e) 18 | { 19 | System.out.println("invalid arg ->"+args[i]); 20 | } 21 | 22 | } 23 | System.out.println("Number of valid arguments "+cntr); 24 | System.out.println("Number of invalid arguments "+(args.length-cntr)); 25 | } 26 | } -------------------------------------------------------------------------------- /Prog79.java: -------------------------------------------------------------------------------- 1 | //some special methods of StringBuffer class 2 | 3 | class Prog79 4 | { 5 | public static void main(String[] args) 6 | { 7 | StringBuffer s = new StringBuffer("Welcome Java"); 8 | System.out.println("initially s contains "+s); 9 | s.insert(8,"to "); 10 | System.out.println("after insert() s contains "+s); 11 | s.setCharAt(8,'T'); 12 | System.out.println("after setChatAt() s contains "+s); 13 | s.append("Programming"); 14 | System.out.println("After append(), s contains " + s); 15 | s.reverse(); 16 | System.out.println("after reverse() s contains "+s); 17 | String s1 = s.toString(); 18 | System.out.println("after toString() s contains "+s+" s1 contains "+s1); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /Prog40.java: -------------------------------------------------------------------------------- 1 | //an example on inheritance 2 | class A 3 | { 4 | int i,j; 5 | void showij() 6 | { 7 | System.out.println("i "+i+" j "+j); 8 | } 9 | } 10 | class B extends A 11 | { 12 | int k; 13 | void showk() 14 | { 15 | System.out.println("k "+k); 16 | } 17 | 18 | int sumijk() 19 | { 20 | return i+j+k; 21 | } 22 | } 23 | 24 | //to execute the program we dont need .java files of class A and class B 25 | //.class files of the same are sufficient 26 | class Prog40 27 | { 28 | public static void main(String[] args) 29 | { 30 | B b = new B(); 31 | b.i = 10; 32 | b.j = 20; 33 | b.k = 30; 34 | 35 | b.showij(); 36 | b.showk(); 37 | 38 | System.out.println("i+j+k "+b.sumijk()); 39 | } 40 | } -------------------------------------------------------------------------------- /Prog75.java: -------------------------------------------------------------------------------- 1 | //example of indexof method which returns position of character present in the String 2 | class Prog75 3 | { 4 | public static void main(String[] args) 5 | { 6 | String name = "databyte"; 7 | int pos_1a = name.indexOf('a'); 8 | int pos_2a = name.indexOf('a',pos_1a+1); //position of a after 1st a 9 | System.out.println("Position of 1st 'a' is "+pos_1a); 10 | System.out.println("Position of 2nd 'a' is "+pos_2a); 11 | 12 | int pos_3a = name.indexOf('a',pos_2a+1); 13 | System.out.println("Position of 3rd 'a' is "+pos_3a);//-1 14 | //returns -1 if elements is not present 15 | } 16 | } 17 | /*There is an another method called String.valueOf() which also can be used to convert Int to String*/ 18 | -------------------------------------------------------------------------------- /Prog82.java: -------------------------------------------------------------------------------- 1 | //accept some text from user and display it char by char until char 'q' encounters 2 | 3 | import java.io.*; //BufferedReaderStream IOException 4 | 5 | class Prog82 6 | { 7 | public static void main(String[] argd) throws IOException 8 | { 9 | //reserve memory to accept data 10 | BufferedInputStream bin = new BufferedInputStream(System.in); 11 | 12 | //System.in collects the keyboard in in the form of byte stream 13 | 14 | System.out.println("Enter some text 'q' to exit :- "); 15 | 16 | while(true) 17 | { 18 | int no = bin.read(); //return ASCII of character 19 | 20 | if((char)no =='q') 21 | break; 22 | 23 | System.out.print((char)no); 24 | } 25 | bin.close(); //memory is released 26 | } 27 | 28 | } -------------------------------------------------------------------------------- /Prog49.java: -------------------------------------------------------------------------------- 1 | /* To prove that in a class hierarchy i.e inheritance, the default 2 | constructor of super class are automatically invoked by sub class 3 | constructor */ 4 | 5 | class A 6 | { 7 | A() 8 | { 9 | System.out.println("Inside the default constructor of A"); 10 | } 11 | } 12 | class B extends A 13 | { 14 | B() 15 | { 16 | //super(); //ok , but not prefered 17 | System.out.println("Inside the default constructor of B"); 18 | } 19 | } 20 | class C extends B 21 | { 22 | C() 23 | { 24 | //super(); //invoked by compiler automatically 25 | System.out.println("Inside the default constructor of C"); 26 | } 27 | } 28 | class Prog49 29 | { 30 | public static void main(String[] args) 31 | { 32 | C obj = new C(); 33 | } 34 | } -------------------------------------------------------------------------------- /Prog45.java: -------------------------------------------------------------------------------- 1 | /* Write a method to increment 2 variables from main() 2 | by 2 different values say 3 and 5. Process is known as 3 | "Call by Value". Result not achieved */ 4 | 5 | class Test 6 | { 7 | int a,b; 8 | } 9 | class Prog45 10 | { 11 | public static void main(String[] args) 12 | { 13 | Test t = new Test(); 14 | 15 | t.a=10; 16 | t.b=20; 17 | 18 | System.out.println("Before incrementing a = "+t.a+" b = "+t.b); 19 | increment(t.a,t.b); 20 | System.out.println("After incrementing a = "+t.a+" b = "+t.b); 21 | } 22 | static void increment(int x,int y) //result is not schieved as we sent fileds of object not a reference of an object 23 | { 24 | x++; 25 | y++; 26 | System.out.println("On incrementing a = "+x+" b = "+y); 27 | } 28 | } -------------------------------------------------------------------------------- /Prog46.java: -------------------------------------------------------------------------------- 1 | /* Write a method to increment 2 variables from main() 2 | by 2 different values say 3 and 5. Process is known as 3 | "Call by Reference". Result achieved */ 4 | 5 | class Test 6 | { 7 | int a,b; 8 | } 9 | class Prog46 10 | { 11 | public static void main(String[] args) 12 | { 13 | Test t = new Test(); 14 | 15 | t.a=10; 16 | t.b=20; 17 | 18 | System.out.println("Before incrementing a = "+t.a+" b = "+t.b); 19 | increment(t); 20 | System.out.println("After incrementing a = "+t.a+" b = "+t.b); 21 | } 22 | static void increment(Test temp) //result is schieved as we sent are creating reference to an object 23 | { 24 | temp.a++; 25 | temp.b++; 26 | System.out.println("On incrementing a = "+temp.a+" b = "+temp.b); 27 | } 28 | } -------------------------------------------------------------------------------- /Prog51.java: -------------------------------------------------------------------------------- 1 | //an example of an abstract class 2 | abstract class A 3 | { 4 | //non abstract method 5 | void callMe() 6 | { 7 | System.out.println("Inside the method callMe()"); 8 | } 9 | 10 | //abstract method 11 | abstract void callMeToo(); 12 | //implementation will be taken care by subclass 13 | } 14 | class B extends A 15 | { 16 | //compulsory to provide implementation to asbtract method 17 | public void callMeToo() 18 | { 19 | System.out.println("Inside the B's implementation of callMeToo()"); 20 | } 21 | } 22 | 23 | class Prog51 24 | { 25 | public static void main(String[] args) 26 | { 27 | //A a = new A(); // A is abstract; cannot be instantiated 28 | B obj = new B(); 29 | 30 | obj.callMe(); 31 | obj.callMeToo(); 32 | } 33 | } -------------------------------------------------------------------------------- /Prog72.java: -------------------------------------------------------------------------------- 1 | //to sort the names of students in array 2 | class Prog72 3 | { 4 | public static void main(String[] args) 5 | { 6 | String[] names = {"makarand","samruddhi","kaustubh","pranjal","tanmay","varad","aditya"}; 7 | int i,j; 8 | System.out.println("Before sorting :-"); 9 | for(i=0;i0) 18 | { 19 | String temp = names[i]; 20 | names[i]=names[j]; 21 | names[j]=temp; 22 | } 23 | } 24 | } 25 | 26 | System.out.println("After sorting :-"); 27 | for(i=0;i int pdt 10 | 11 | String istr = Integer.toString(ival); //Integer->String 12 | 13 | int istrval = Integer.parseInt(istr); //String->int 14 | 15 | System.out.println("i contains " + i); 16 | System.out.println("obji contains " + obji); 17 | System.out.println("ival contains " + ival); 18 | System.out.println("istr contains " + istr); 19 | System.out.println("istrval contains " + istrval); 20 | System.out.println("istr + istr contains " + (istr + istr)); 21 | System.out.println("istrval+istrval contains " + (istrval + istrval)); 22 | } 23 | } -------------------------------------------------------------------------------- /Prog38.java: -------------------------------------------------------------------------------- 1 | //eg constructor overloading 2 | 3 | 4 | class Room 5 | { 6 | int length,breadth; 7 | public Room(int l,int b) 8 | { 9 | length=l; 10 | breadth=b; 11 | 12 | } 13 | public Room(int s) 14 | { 15 | length=s; 16 | breadth=s; 17 | } 18 | public int getArea() 19 | { 20 | return length*breadth; 21 | } 22 | public int getPerimeter() 23 | { 24 | return 2*(length+breadth); 25 | } 26 | } 27 | class Prog38 28 | { 29 | public static void main(String[] args) 30 | { 31 | Room r1 = new Room(10); 32 | 33 | Room r2 = new Room(10,20); 34 | 35 | System.out.println("Area of r1 is "+r1.getArea()); 36 | System.out.println("Perimeter of r1 is "+r1.getPerimeter()); 37 | 38 | System.out.println("Area of r2 is "+r2.getArea()); 39 | System.out.println("Perimeter of r2 is "+r2.getPerimeter()); 40 | 41 | } 42 | } -------------------------------------------------------------------------------- /Prog50.java: -------------------------------------------------------------------------------- 1 | /* To prove in inheritance, even the parameterised constructor of sub class 2 | can invoke the default constructor of super class provided they do not 3 | invoke the parameterised constructor of super class 4 | */ 5 | 6 | 7 | class A 8 | { 9 | A() 10 | { 11 | System.out.println("Inside the default constructor of A"); 12 | } 13 | } 14 | class B extends A 15 | { 16 | B(int x) 17 | { 18 | //super(); //ok , but not prefered 19 | System.out.println("Inside the parameterised constructor of B"); 20 | } 21 | } 22 | class C extends B 23 | { 24 | C(int x) 25 | { 26 | super(x); 27 | //super(); //not invoked by compiler automatically 28 | System.out.println("Inside the parameterized constructor of C"); 29 | } 30 | } 31 | class Prog50 32 | { 33 | public static void main(String[] args) 34 | { 35 | C obj = new C(10); 36 | } 37 | } -------------------------------------------------------------------------------- /Prog56.java: -------------------------------------------------------------------------------- 1 | //an eg of toString() of object class 2 | class Emp 3 | { 4 | private int empid; 5 | private String name; 6 | private double sal; 7 | 8 | public Emp(int id,String n,double s) 9 | { 10 | empid=id; 11 | name=n; 12 | sal=s; 13 | } 14 | //ovveride toString() method 15 | public String toString() 16 | { 17 | return "Empid:- "+empid+" name:-"+name+" salary:-"+sal; 18 | } 19 | 20 | } 21 | class Prog56 22 | { 23 | public static void main(String[] args) 24 | { 25 | Emp e1 = new Emp(1,"Ramesh",10000); 26 | Emp e2 = new Emp(2,"Suresh",12000); 27 | 28 | System.out.println("e1 contains "+e1.toString()); 29 | System.out.println("e2 contains "+e2.toString()); 30 | 31 | //toString() is a method in Object class which returns address of object 32 | //all classes are by edefault subclasses of Object class 33 | } 34 | } -------------------------------------------------------------------------------- /Prog89.java: -------------------------------------------------------------------------------- 1 | //design an applet to wish user depending upon the time of the day 2 | 3 | import java.applet.*; //applet class 4 | import java.awt.*; //graphics ,font,color 5 | import java.util.Date; 6 | 7 | /**/ 8 | 9 | public class Prog89 extends Applet 10 | { 11 | 12 | public void init() 13 | { 14 | 15 | setFont (new Font("Arial",Font.BOLD,25)); 16 | } 17 | public void paint(Graphics g) 18 | { 19 | //create an instance of Date class 20 | 21 | Date d = new Date(); 22 | 23 | int hrs = d.getHours(); //will return time in hrs , 24 hr format 24 | 25 | String msg = "Good "; 26 | 27 | if(hrs<12) 28 | msg+="morning"; 29 | 30 | else if(hrs<16) 31 | msg+="afternoon"; 32 | 33 | else 34 | msg+=" night"; 35 | 36 | g.drawString(msg,150,150); 37 | } 38 | 39 | } -------------------------------------------------------------------------------- /Prog41.java: -------------------------------------------------------------------------------- 1 | //an example private members of superclass 2 | class A 3 | { 4 | private int i; 5 | int j; 6 | void showij() 7 | { 8 | System.out.println("i "+i+" j "+j); 9 | } 10 | void seti(int x) 11 | { 12 | i=x; 13 | } 14 | int geti() 15 | { 16 | return i; 17 | } 18 | } 19 | class B extends A 20 | { 21 | int k; 22 | void showk() 23 | { 24 | System.out.println("k "+k); 25 | } 26 | 27 | int sumijk() 28 | { 29 | 30 | return geti()+j+k; 31 | } 32 | } 33 | 34 | 35 | class Prog41 36 | { 37 | public static void main(String[] args) 38 | { 39 | //here i,j,showij() are available but i is not accessible 40 | B b = new B(); 41 | //b.i = 10;//error: i has private access in A 42 | b.seti(10); 43 | b.j = 20; 44 | b.k = 30; 45 | 46 | b.showij(); 47 | b.showk(); 48 | 49 | System.out.println("i+j+k "+b.sumijk()); 50 | } 51 | } -------------------------------------------------------------------------------- /Prog37.java: -------------------------------------------------------------------------------- 1 | //eg 2 on method overloading 2 | 3 | 4 | class Test 5 | { 6 | void test(float f) 7 | { 8 | System.out.println("Invocation of test(float)"); 9 | } 10 | 11 | void test(byte b) 12 | { 13 | System.out.println("Invocation of test(byte)"); 14 | } 15 | void test(long l) 16 | { 17 | System.out.println("Invocation of test(long)"); 18 | } 19 | 20 | } 21 | class Prog37 22 | { 23 | public static void main(String[] args) 24 | { 25 | Test t = new Test(); 26 | 27 | 28 | byte b=10; 29 | short s=10; 30 | int i=10; 31 | long l=10; 32 | float f=10; 33 | double d=10; 34 | 35 | t.test(b); //byte 36 | t.test(s); //long 37 | t.test(i); //long 38 | t.test(l); //long 39 | t.test(f); //float 40 | //t.test(d); //error no suitable method found for test(double) 41 | t.test((float)d); //explicit typecast 42 | } 43 | } -------------------------------------------------------------------------------- /Prog81.java: -------------------------------------------------------------------------------- 1 | //an exmple on Math class 2 | class Prog81 3 | { 4 | public static void main(String[] args) 5 | { 6 | System.out.println("some random numbers are :-"); 7 | for(int i=0;i*/ 7 | 8 | public class Prog88 extends Applet 9 | { 10 | //decalre variables globally so they are accessible by standard methods 11 | String msg; 12 | Font f; 13 | 14 | public void init() 15 | { 16 | msg = "Welcome to Java"; 17 | f = new Font("Chiller",Font.BOLD|Font.ITALIC,25); 18 | 19 | /*Font accepts 3 args* 20 | 1 - Font name as string 21 | 2 - Font style as constant 22 | 3 - font size 23 | */ 24 | 25 | this.setFont(f); 26 | 27 | setBackground(Color.BLACK); 28 | setForeground(Color.YELLOW); 29 | 30 | /*these are also called by this keyword. 31 | They are present in component class*/ 32 | 33 | 34 | } 35 | public void paint(Graphics g) 36 | { 37 | g.drawString(msg,150,150); 38 | } 39 | 40 | } -------------------------------------------------------------------------------- /Prog28.java: -------------------------------------------------------------------------------- 1 | //Design class "Rectangle" with suitable attributes and methods 2 | //to calculate area and perimeter 3 | 4 | class Rectangle 5 | { 6 | int length,breadth; 7 | /*in java we have only two types of methods in, setter and getter 8 | setter methods are called as mutator methods and with return 9 | type void an argument list*/ 10 | public void setParam(int l,int b) 11 | { 12 | length=l; 13 | breadth=b; 14 | } 15 | /*getter methods are generally nonvoid methods,does not require 16 | any argument list 17 | process on fields of objects*/ 18 | public double getArea() 19 | { 20 | return length*breadth; 21 | } 22 | public double getPerimeter() 23 | { 24 | return 2*(length+breadth); 25 | } 26 | } 27 | class Prog28 28 | { 29 | public static void main(String[] args) 30 | { 31 | Rectangle r = new Rectangle(); 32 | 33 | r.setParam(20,50); 34 | 35 | System.out.println("Area of rectangle r is "+r.getArea()+" perimeter is "+r.getPerimeter()); 36 | } 37 | } -------------------------------------------------------------------------------- /Prog26.java: -------------------------------------------------------------------------------- 1 | //accept records of employee and display their details 2 | 3 | import java.util.Scanner; 4 | //Scanner class resides in util package 5 | //and not lang package , hence we need to import it 6 | 7 | class Prog26 8 | { 9 | public static void main(String[] args) 10 | { 11 | //creating an instance of Scanner class 12 | Scanner sc = new Scanner(System.in); 13 | 14 | //system.in respresents input from keyboard 15 | System.out.println("Enter emp_id :-"); 16 | int emp_id = sc.nextInt(); 17 | 18 | sc.nextLine(); //clear buffer 19 | System.out.println("Enter emp_name :-"); 20 | String emp_name = sc.nextLine(); //to accept string with spaces 21 | 22 | sc.nextLine(); //clear buffer 23 | 24 | System.out.println("Enter emp_desig :-"); 25 | String emp_desig = sc.nextLine(); 26 | 27 | System.out.println("Enter emp_sal :-"); 28 | double emp_sal = sc.nextDouble(); 29 | 30 | System.out.println("emp_id :-"+emp_id+" emp_name:-"+emp_name+" emp_desig:-"+emp_desig+" emp_sal:-"+emp_sal); 31 | } 32 | } -------------------------------------------------------------------------------- /Prog64.java: -------------------------------------------------------------------------------- 1 | /*Accept the age of a person to be insured between 10-60 years only and 2 | display it. Handle the following exceptions: 3 | if age<10 throw "AgeTooSmallException" 4 | if age>50 throw "AgeTooLargeException" 5 | handle standard exceptions if any */ 6 | class MyException extends Exception 7 | { 8 | MyException(String msg) 9 | { 10 | super(msg); 11 | } 12 | } 13 | 14 | class Prog64 15 | { 16 | public static void main(String[] args) 17 | { 18 | try 19 | { 20 | int age=Integer.parseInt(args[0]); 21 | if(age<10) 22 | throw new MyException("AgeTooSamllException"); 23 | 24 | else if(age>50) 25 | throw new MyException("AgeTooLargeException"); 26 | 27 | else 28 | System.out.println("Age seems to be fine , you can proceed further"); 29 | } 30 | catch(MyException e) 31 | { 32 | System.out.println("Error:- "+e.getMessage()); 33 | } 34 | catch(NumberFormatException e) 35 | { 36 | System.out.println("Error:- "+e.getMessage()); 37 | } 38 | catch(ArrayIndexOutOfBoundsException e) 39 | { 40 | System.out.println("Error:- please provide the age"); 41 | } 42 | } 43 | } -------------------------------------------------------------------------------- /Prog32.java: -------------------------------------------------------------------------------- 1 | /*Design a class "Student" with attributes rollno,name and percent. 2 | Accept data of a few students and at the end, display their records 3 | along with number of records/objects created. */ 4 | 5 | class Student 6 | { 7 | private int rollno; 8 | private String name; 9 | private double percent; 10 | private static int cntr; 11 | public Student(int r,String n,double p) 12 | { 13 | name=n; 14 | rollno=r; 15 | percent=p; 16 | cntr++; 17 | display(); 18 | } 19 | public void display() 20 | { 21 | System.out.println("Name :"+name); 22 | System.out.println("Rollno :"+rollno); 23 | System.out.println("Percentage :"+percent); 24 | } 25 | public static int getCntr() 26 | { 27 | //instance member cannot be referd using statuc method 28 | return cntr; 29 | } 30 | } 31 | class Prog32 32 | { 33 | public static void main(String[] args) 34 | { 35 | Student s1 = new Student(10,"Makya",69.346); 36 | Student s2 = new Student(12,"Makyabhau",99.99); 37 | Student s3 = new Student(14,"Makyasheth",78.2354); 38 | 39 | System.out.println("Number of students are :"+Student.getCntr()); 40 | } 41 | } -------------------------------------------------------------------------------- /Prog98.java: -------------------------------------------------------------------------------- 1 | //an example on anonymous inner classes 2 | //design a program in which background colour changes to red,gree,blue onclivk of left,center and right mouse buttons 3 | //use anonymous inner class 4 | 5 | import java.awt.*; 6 | import java.awt.event.*; 7 | 8 | class Prog98 extends Frame 9 | { 10 | public static void main(String[] args) 11 | { 12 | new Prog98(); 13 | } 14 | Prog98() 15 | { 16 | setBounds(250,125,500,500); 17 | //register the mouse with frame to deal with events 18 | addMouseListener(new MouseAdapter() 19 | 20 | //define new inner class without name but which inherits MouseAdapter 21 | { 22 | //override the reqd method 23 | public void mouseClicked(MouseEvent me) 24 | { 25 | //check which button is clicked 26 | if(me.getButton()==1) //left Button 27 | setBackground(Color.RED); 28 | 29 | else if(me.getButton()==2) 30 | setBackground(Color.GREEN); 31 | 32 | else setBackground(Color.BLUE); 33 | } 34 | }); 35 | 36 | addWindowListener(new WindowAdapter() 37 | { 38 | public void windowClosing(WindowEvent we) 39 | { 40 | System.exit(0); 41 | } 42 | }); 43 | 44 | setVisible(true); 45 | }//end of constructor 46 | }//end of class -------------------------------------------------------------------------------- /Prog58.java: -------------------------------------------------------------------------------- 1 | //to prove than interfaces as well as abstract classes can inherit 2 | 3 | interface X 4 | { 5 | void methX(); 6 | } 7 | 8 | //error : as interfaces only contains abstract methods ,they cannot implement each other 9 | /*interface Y implements X 10 | { 11 | 12 | }*/ 13 | 14 | interface Y extends X 15 | { 16 | void methY(); 17 | } 18 | abstract class A implements Y 19 | { 20 | //as a class is abstract it is not necessary to provide implementation 21 | //for each and every method 22 | abstract void methA(); 23 | } 24 | abstract class B extends A 25 | { 26 | public void methY() 27 | { 28 | //not compulsory 29 | System.out.println("B's implementation of methY()"); 30 | } 31 | } 32 | class C extends B 33 | { 34 | //as class is non abstract 35 | //it is compulsory to provide 36 | //implementation to all abstract methods present in previous class 37 | public void methX() 38 | { 39 | System.out.println("C's implementation of methX()"); 40 | } 41 | 42 | public void methA() 43 | { 44 | System.out.println("C's implementation of methA()"); 45 | } 46 | } 47 | 48 | class Prog58 49 | { 50 | public static void main(String[] args) 51 | { 52 | C obj = new C(); 53 | obj.methA(); 54 | obj.methX(); 55 | obj.methY(); 56 | } 57 | } -------------------------------------------------------------------------------- /Prog86.java: -------------------------------------------------------------------------------- 1 | //accept source and target from user and copy the contents of source into target 2 | 3 | import java.io.*; 4 | import java.util.Scanner; 5 | 6 | class Prog86 7 | { 8 | public static void main(String[] args) throws IOException 9 | { 10 | Scanner sc = new Scanner(System.in); 11 | 12 | System.out.print("Enter sourcefile name : "); 13 | String source = sc.next(); 14 | 15 | System.out.print("Enter targetfile name : "); 16 | String target = sc.next(); 17 | 18 | //wrong style 19 | 20 | BufferedReader br= new BufferedReader(new InputStreamReader(System.in)); 21 | 22 | try 23 | { 24 | FileInputStream fin = new FileInputStream(source); 25 | 26 | FileOutputStream fout = new FileOutputStream(target,false); 27 | 28 | /*second option is boolean append with default value set to 29 | false. It means if target file does not exist ,create one and if it exists 30 | overwrite it. 31 | */ 32 | //setting append to true will append the content of target file 33 | //with source file 34 | 35 | while(true) 36 | { 37 | int no = fin.read(); 38 | 39 | if(no==-1) 40 | break; 41 | 42 | fout.write((char)no); 43 | } 44 | fin.close(); 45 | fout.close(); 46 | } 47 | catch(FileNotFoundException e) 48 | { 49 | System.out.println("Source file not found."); 50 | } 51 | br.close(); 52 | } 53 | } -------------------------------------------------------------------------------- /Prog90.java: -------------------------------------------------------------------------------- 1 | //design an applet with 2 buttons if clicked will change the background 2 | 3 | import java.applet.*; //applet class 4 | import java.awt.*; //graphics ,font,color 5 | import java.awt.event.*;//ctionListener interface 6 | /**/ 7 | 8 | public class Prog90 extends Applet 9 | { 10 | Button btnorange,btngreen; 11 | public void init() 12 | { 13 | //orange is caption 14 | btnorange = new Button("Orange"); 15 | btngreen = new Button("Green"); 16 | 17 | setLayout(null); 18 | btnorange.setBounds(120,100,100,70); 19 | btngreen.setBounds(250,100,100,70); 20 | 21 | //add button to applet interface 22 | add(btngreen); 23 | add(btnorange); 24 | 25 | //register the events 26 | BtnHanlder list_obj = new BtnHanlder(); 27 | 28 | btnorange.addActionListener(list_obj); 29 | btngreen.addActionListener(list_obj); 30 | 31 | setFont (new Font("Arial",Font.BOLD,25)); 32 | setVisible(true); 33 | } 34 | //the listener object has to be inner class so it can access buttin object 35 | 36 | class BtnHanlder implements ActionListener 37 | { 38 | public void actionPerformed(ActionEvent ae) 39 | { 40 | //check which button is clicked 41 | 42 | if(ae.getSource() == btnorange) 43 | setBackground(Color.ORANGE); 44 | 45 | else 46 | setBackground(Color.GREEN); 47 | } 48 | } 49 | } -------------------------------------------------------------------------------- /Prog96.java: -------------------------------------------------------------------------------- 1 | //and examlple of frame registered with hardware devices 2 | //we want co-ordinates of mouse as we hover it on screena and character entered from keyboard 3 | 4 | import java.awt.*; 5 | import java.awt.event.*; 6 | 7 | public class Prog96 extends Frame 8 | { 9 | String msg1="",msg2=""; 10 | public static void main(String[] args) 11 | { 12 | new Prog96(); 13 | } 14 | public Prog96() 15 | { 16 | setTitle("Hardware Registered Frame"); 17 | setBounds(250,125,500,500); 18 | setFont(new Font("Times New Roman",Font.BOLD,25)); 19 | 20 | //register the frame 21 | //shortcut, use anonymous object 22 | 23 | addMouseMotionListener(new MyMouseAdapter()); 24 | addKeyListener(new MyKeyAdapter()); 25 | 26 | setVisible(true); 27 | } 28 | //inner class for event handling 29 | //because we have learnt that inner class can access all the members of outer scope 30 | class MyMouseAdapter extends MouseMotionAdapter 31 | { 32 | //override the reqd method 33 | public void mouseMoved(MouseEvent me) 34 | { 35 | msg1="Mouse moved to : "+me.getX()+","+me.getY(); 36 | repaint(); 37 | } 38 | } 39 | class MyKeyAdapter extends KeyAdapter 40 | { 41 | //override the reqd mrthod 42 | public void keyTyped(KeyEvent ke){ 43 | msg2="Character entered from keyboard : "+ke.getKeyChar(); 44 | repaint(); 45 | } 46 | } 47 | public void paint(Graphics g) 48 | { 49 | g.drawString(msg1,50,100); 50 | g.drawString(msg2,50,170); 51 | } 52 | } -------------------------------------------------------------------------------- /Prog91.java: -------------------------------------------------------------------------------- 1 | //similar to Prog90 where container class can be assigned to manage events 2 | 3 | import java.applet.*; //applet class 4 | import java.awt.*; //graphics ,font,color 5 | import java.awt.event.*;//ctionListener interface 6 | /**/ 7 | 8 | public class Prog91 extends Applet implements ActionListener 9 | { 10 | Button btnorange,btngreen; 11 | public void init() 12 | { 13 | //orange is caption 14 | btnorange = new Button("Orange"); 15 | btngreen = new Button("Green"); 16 | 17 | setLayout(null); 18 | btnorange.setBounds(120,100,100,70); 19 | btngreen.setBounds(250,100,100,70); 20 | 21 | //add button to applet interface 22 | add(btngreen); 23 | add(btnorange); 24 | 25 | //register the events 26 | //BtnHanlder list_obj = new BtnHanlder(); 27 | 28 | //btnorange.addActionListener(list_obj); 29 | //btngreen.addActionListener(list_obj); 30 | 31 | btnorange.addActionListener(this); 32 | btngreen.addActionListener(this); 33 | 34 | setFont (new Font("Arial",Font.BOLD,25)); 35 | setVisible(true); 36 | } 37 | //the listener object has to be inner class so it can access buttin object 38 | 39 | 40 | 41 | public void actionPerformed(ActionEvent ae) 42 | { 43 | //check which button is clicked 44 | 45 | if(ae.getSource() == btnorange) 46 | setBackground(Color.ORANGE); 47 | 48 | else 49 | setBackground(Color.GREEN); 50 | } 51 | 52 | } -------------------------------------------------------------------------------- /Prog76.java: -------------------------------------------------------------------------------- 1 | //validation of email 2 | class Prog76 3 | { 4 | public static void main(String[] args) 5 | { 6 | try 7 | { 8 | String email = args[0]; 9 | //check for presence of @ 10 | int pos_1a = email.indexOf('@'); 11 | if(pos_1a==-1) 12 | { 13 | System.out.println("Missing @ in email"); 14 | } 15 | else 16 | { 17 | //check for presence of multiple @ 18 | int pos_2a = email.indexOf('@',pos_1a+1); 19 | if(pos_2a!=-1) 20 | { 21 | System.out.println("Email contains multiple @"); 22 | } 23 | else 24 | { 25 | //chech for username 26 | if(pos_1a==0) 27 | { 28 | System.out.println("Missing username"); 29 | } 30 | else 31 | { 32 | int pos_dot_afat = email.indexOf('.',pos_1a+1); 33 | 34 | if(pos_dot_afat==pos_1a+1) 35 | { 36 | System.out.println("Missing user name"); 37 | } 38 | else 39 | { 40 | if(pos_dot_afat==-1) 41 | { 42 | System.out.println("Missing domain name"); 43 | } 44 | else 45 | { 46 | String domain = email.substring(pos_dot_afat+1); 47 | if(domain.length()<2) 48 | System.out.println("Enter correct domain name"); 49 | else 50 | System.out.println("Email seems to be okay"); 51 | } 52 | } 53 | } 54 | } 55 | } 56 | } 57 | catch(ArrayIndexOutOfBoundsException e) 58 | { 59 | System.out.println("Please enter email"); 60 | } 61 | } 62 | } -------------------------------------------------------------------------------- /Prog95.java: -------------------------------------------------------------------------------- 1 | //design the frame with 2 textfields to accept 2 numbers from user and display their sum 2 | import java.awt.*; 3 | import java.awt.event.*; 4 | class Prog95 extends Frame implements ActionListener 5 | { 6 | Label l1,l2,result; 7 | TextField t1,t2; 8 | public static void main(String[] args) 9 | { 10 | new Prog95(); 11 | } 12 | public Prog95() 13 | { 14 | setTitle("Addtion"); 15 | setBounds(250,125,500,500); 16 | 17 | setLayout(null);//manual 18 | 19 | l1 = new Label("Number 1"); 20 | l2 = new Label("Number 2"); 21 | result = new Label(""); 22 | t1 = new TextField(""); 23 | t2 = new TextField(""); 24 | 25 | l1.setBounds(50,50,100,30); 26 | l2.setBounds(50,100,100,30); 27 | t1.setBounds(170,50,100,30); 28 | t2.setBounds(170,100,100,30); 29 | result.setBounds(50,200,150,50); 30 | add(l1); 31 | add(l2); 32 | add(t1); 33 | add(t2); 34 | add(result); 35 | 36 | t1.addActionListener(this); 37 | t2.addActionListener(this); 38 | //to manage window events create an object of MyWindowAdapter which is a user defined class 39 | MyWindowAdapter myAdapter = new MyWindowAdapter(); 40 | addWindowListener(myAdapter); 41 | setVisible(true); 42 | } 43 | public void actionPerformed(ActionEvent ae) 44 | { 45 | try 46 | { 47 | int no1 = Integer.parseInt(t1.getText()); 48 | int no2 = Integer.parseInt(t2.getText()); 49 | 50 | result.setText("Sum of "+no1+" and "+no2+" is : " +(no1+no2)); 51 | } 52 | catch(NumberFormatException e) 53 | { 54 | result.setText("Please enter integers only"); 55 | } 56 | } 57 | //inner class 58 | class MyWindowAdapter extends WindowAdapter 59 | { 60 | //override reqd method of interface 61 | public void windowClosing(WindowEvent we) 62 | { 63 | System.exit(0); 64 | } 65 | } 66 | } -------------------------------------------------------------------------------- /Parent_Frame.java: -------------------------------------------------------------------------------- 1 | //example on parent and child frame 2 | 3 | import java.awt.*; 4 | import java.awt.event.*; 5 | 6 | class Parent_Frame extends Frame implements ActionListener 7 | { 8 | Button btnchild,btnexit; 9 | public static void main(String[] args) 10 | { 11 | new Parent_Frame(); 12 | } 13 | Parent_Frame() 14 | { 15 | 16 | setTitle("Parent Frame"); 17 | setBounds(250,125,500,500); 18 | setFont(new Font("Times New Roman",Font.BOLD,25)); 19 | setLayout(null); 20 | btnchild = new Button("open child"); 21 | btnexit = new Button("exit"); 22 | 23 | btnchild.setBounds(50,400,150,30); 24 | btnexit.setBounds(220,400,100,30); 25 | 26 | add(btnexit); 27 | add(btnchild); 28 | 29 | btnchild.addActionListener(this); 30 | btnexit.addActionListener(this); 31 | setVisible(true); 32 | } 33 | public void actionPerformed(ActionEvent ae) 34 | { 35 | if(ae.getSource()==btnchild) 36 | { 37 | //dispose(); //if next frame is not child 38 | new Child_Frame();//call the child frame using constructor 39 | } 40 | else 41 | System.exit(0); 42 | } 43 | 44 | //child Frame 45 | class Child_Frame extends Frame implements ActionListener 46 | { 47 | Button btnclose; 48 | //IMP - do not use main() 49 | //main() should be only associated with starting frame of application 50 | 51 | //constructor 52 | Child_Frame() 53 | { 54 | setTitle("Child Frame"); 55 | setBounds(400,275,200,200); 56 | setFont(new Font("Times New Roman",Font.BOLD,25)); 57 | setLayout(new FlowLayout()); 58 | btnclose = new Button("Close"); 59 | add(btnclose); 60 | 61 | btnclose.addActionListener(this); 62 | setVisible(true); 63 | } 64 | public void actionPerformed(ActionEvent ae) 65 | { 66 | dispose(); //close this frame and go back to calling/parent frame 67 | } 68 | }//end of child frame 69 | }//end of parent frame -------------------------------------------------------------------------------- /Prog93.java: -------------------------------------------------------------------------------- 1 | //an assignment on radio buttons 2 | 3 | import java.awt.*; 4 | import java.awt.event.*; 5 | import java.applet.*; 6 | 7 | // 8 | public class Prog93 extends Applet implements ItemListener 9 | { 10 | Label l1,l2; 11 | Checkbox radm,radum,radl25,radb2550,radg50; 12 | CheckboxGroup rbg1,rbg2; 13 | public void init() 14 | { 15 | setFont (new Font("Arial",Font.BOLD,25)); 16 | setLayout(null); 17 | 18 | l1 = new Label("Marital Status"); 19 | rbg1 = new CheckboxGroup(); 20 | 21 | radm = new Checkbox("Married",rbg1,false); 22 | radum = new Checkbox("Unmarried",rbg1,true); 23 | 24 | l1.setBounds(50,50,180,30); 25 | radm.setBounds(50,100,150,30); 26 | radum.setBounds(230,100,150,30); 27 | 28 | add(l1); 29 | add(radm); 30 | add(radum); 31 | 32 | radm.addItemListener(this); 33 | radum.addItemListener(this); 34 | 35 | l2 = new Label("Income Group"); 36 | 37 | rbg2 = new CheckboxGroup(); 38 | radl25 = new Checkbox("<25K",rbg2,true); 39 | radb2550 = new Checkbox("25K< >50k",rbg2,false); 40 | radg50= new Checkbox(">50K",rbg2,false); 41 | 42 | l2.setBounds(50,220,200,30); 43 | radl25.setBounds(10,280,150,30); 44 | radb2550.setBounds(160,280,150,30); 45 | radg50.setBounds(340,280,150,30); 46 | 47 | add(l2); 48 | add(radl25); 49 | add(radb2550); 50 | add(radg50); 51 | 52 | radl25.addItemListener(this); 53 | radb2550.addItemListener(this); 54 | radg50.addItemListener(this); 55 | setVisible(true); 56 | } 57 | 58 | public void itemStateChanged(ItemEvent ie) 59 | { 60 | repaint(); 61 | } 62 | 63 | public void paint(Graphics g) 64 | { 65 | g.setColor(Color.red); 66 | g.drawString("I am "+rbg1.getSelectedCheckbox().getLabel(),50,160); 67 | 68 | g.drawString("My income is "+rbg2.getSelectedCheckbox().getLabel(),50,340); 69 | } 70 | } -------------------------------------------------------------------------------- /Prog97.java: -------------------------------------------------------------------------------- 1 | //and example on menu driven program 2 | //design the menu driven program with 2 menus file and format 3 | //file -> exit 4 | //format -> bold,italic 5 | import java.awt.*; 6 | import java.awt.event.*; 7 | class Prog97 extends Frame implements ActionListener,ItemListener 8 | { 9 | MenuBar mbar; 10 | Menu mfile,mformat; 11 | MenuItem mexit; 12 | CheckboxMenuItem mbold,mitalic; 13 | Label l ; 14 | Font f; 15 | public static void main(String[] args) 16 | { 17 | new Prog97(); 18 | } 19 | 20 | Prog97() 21 | { 22 | setTitle("Menu Driven Program"); 23 | setBounds(250,125,600,600); 24 | //setLayout(new Layout()); 25 | 26 | mbar = new MenuBar(); 27 | mfile = new Menu("File"); 28 | mformat = new Menu("Format"); 29 | mexit = new MenuItem("Exit"); 30 | mbold = new CheckboxMenuItem("Bold"); 31 | mitalic = new CheckboxMenuItem("Italic"); 32 | l = new Label("Databyte Computer Training Center , Pune "); 33 | 34 | f = new Font("Times New Roman",Font.BOLD,25); //defualt font settings 35 | l.setFont(f); 36 | 37 | setMenuBar(mbar); 38 | mbar.add(mfile); 39 | mbar.add(mformat); 40 | mfile.add(mexit); 41 | mformat.add(mbold); 42 | mformat.add(mitalic); 43 | 44 | add(l); 45 | 46 | mexit.addActionListener(this); 47 | mbold.addItemListener(this); 48 | mitalic.addItemListener(this); 49 | 50 | setVisible(true); 51 | } 52 | public void actionPerformed(ActionEvent ae) 53 | { 54 | System.exit(0); 55 | } 56 | public void itemStateChanged(ItemEvent ie) 57 | { 58 | if(mbold.getState()) 59 | { 60 | if(mitalic.getState()) 61 | f = new Font("New Times Roman",Font.BOLD|Font.ITALIC,25); 62 | else 63 | f = new Font("Times New Roman",Font.BOLD,25); 64 | } 65 | else{ 66 | if(mbold.getState()) 67 | f = new Font("New Times Roman",Font.ITALIC,25); 68 | else 69 | f = new Font("Times New Roman",Font.PLAIN,25); 70 | } 71 | l.setFont(f); 72 | } 73 | } -------------------------------------------------------------------------------- /Prog92.java: -------------------------------------------------------------------------------- 1 | //design an applet to manage checkboxes 2 | 3 | import java.awt.*; 4 | import java.awt.event.*; 5 | import java.applet.*; 6 | 7 | // 8 | public class Prog92 extends Applet implements ItemListener 9 | { 10 | Label l; 11 | Checkbox chbhome,chbmobile,chbPC; 12 | 13 | public void init() 14 | { 15 | setFont(new Font("Arial",Font.BOLD,25)); 16 | 17 | //create object of label and checkboxes 18 | 19 | l = new Label("I own "); 20 | chbhome = new Checkbox("Home",true); 21 | 22 | //2nd arguement is optional with default value false can be changed to true 23 | 24 | chbPC = new Checkbox("PC"); 25 | chbmobile = new Checkbox("Mobile"); 26 | 27 | chbhome.setEnabled(false); //checkbox is disabled 28 | 29 | //by default it is autolayout i.e. JRE checks size pf containers and components 30 | 31 | setLayout(null); //null means manual layout 32 | 33 | l.setBounds(50,50,100,30); 34 | chbhome.setBounds(50,120,150,30); 35 | chbPC.setBounds(50,170,150,30); 36 | chbmobile.setBounds(50,220,150,30); 37 | 38 | add(l); 39 | add(chbhome); 40 | add(chbPC); 41 | add(chbmobile); 42 | 43 | 44 | 45 | 46 | //register only enabled checkboxes 47 | chbPC.addItemListener(this); 48 | chbmobile.addItemListener(this); 49 | 50 | setVisible(true); 51 | } 52 | //override all methods of ItemListener 53 | 54 | public void itemStateChanged(ItemEvent ie) 55 | { 56 | //call the paint() 57 | repaint();//we need to do this because to write on applet window we need Graphics object 58 | } 59 | public void paint(Graphics g) 60 | { 61 | g.setColor(Color.red); 62 | g.drawString("Status ",50,300); 63 | //text to write , left , top 64 | 65 | g.setColor(Color.blue); 66 | g.drawString("Home - true",50,350); 67 | g.drawString("PC - "+chbPC.getState(),50,400); 68 | g.drawString("Mobile - "+chbmobile.getState(),50,450); 69 | 70 | } 71 | }//end of class 72 | 73 | 74 | 75 | 76 | 77 | 78 | -------------------------------------------------------------------------------- /Prog65.java: -------------------------------------------------------------------------------- 1 | /* Accept a binary expression from user as cmd argument and evaluate it. 2 | Handle the following exceptions:- 3 | 1. if no. of arguments are not valid 4 | throw "InvalidNoOfArgsException" 5 | 2. if opertor is invalid 6 | throw "InvalidOperatorException" 7 | 3. if result is -ve 8 | thorw "NegativeResultException" 9 | 4. Handle other standard exceptions if any 10 | */ 11 | 12 | class MyException extends Throwable 13 | { 14 | public MyException(String msg) 15 | { 16 | super(msg); 17 | } 18 | } 19 | class Prog65 20 | { 21 | public static void main(String[] args) 22 | { 23 | try 24 | { 25 | if(args.length!=3) 26 | throw new MyException("InvalidNumberOfArgumentsException"); 27 | 28 | char ch = args[1].charAt(0); 29 | if(ch!='+' && ch!='-' && ch!='/' && ch!='*' && ch!='%' && ch!='$') 30 | throw new MyException("Please enter the valid operator"); 31 | double result; 32 | double num1 = Double.parseDouble(args[0]); 33 | double num2 = Double.parseDouble(args[2]); 34 | 35 | switch(ch) 36 | { 37 | case '+': 38 | result=num1+num2; 39 | break; 40 | case '-': 41 | result=num1-num2; 42 | break; 43 | case '*': 44 | result=num1*num2; 45 | break; 46 | case '/': 47 | result=num1/num2; 48 | break; 49 | case '%': 50 | result=num1%num2; 51 | break; 52 | default: 53 | result=Math.pow(num1,num2); 54 | break; 55 | } 56 | if(result<0) 57 | throw new MyException("Result is negative"); 58 | 59 | System.out.println("Result of operation "+result); 60 | } 61 | catch(NumberFormatException e) 62 | { 63 | System.out.println("Please provide numbers only"); 64 | } 65 | catch(MyException e) 66 | { 67 | System.out.println(e.getMessage()); 68 | } 69 | /*to handle unknows exceptions which may occur @runtime. This exceptiom handler should 70 | be @the end of other catch statements, otherwise we get compile error. Based on Dynamic method 71 | Dispatch */ 72 | catch(Exception e) 73 | { 74 | System.out.println(e.getMessage()); 75 | } 76 | } 77 | } -------------------------------------------------------------------------------- /Prog52.java: -------------------------------------------------------------------------------- 1 | /* Eg-2 of abstract class. Define a class "Shape" to manage 2D shapes 2 | with suitable attributes and a method to calculate area of any given 2D shape. 3 | Define a class "Rectangle" which inherits "Shape". Define "Triangle" which 4 | inherits "Shape". Accept n shapes from user and display their area. 5 | 6 | Logic:- As the formula/expression to calculate area of different shapes is 7 | different, we have to declare getArea() as abstract */ 8 | 9 | import java.util.Scanner; 10 | abstract class Shape 11 | { 12 | protected int dim1,dim2; 13 | 14 | Shape(int d1,int d2) 15 | { 16 | dim1=d1; 17 | dim2=d2; 18 | } 19 | abstract double getArea(); 20 | 21 | } 22 | class Rectangle extends Shape 23 | { 24 | Rectangle(int d1,int d2) 25 | { 26 | super(d1,d2); 27 | 28 | } 29 | public double getArea() //compulsory overrinding 30 | { 31 | return dim1*dim2; 32 | } 33 | } 34 | class Triangle extends Shape 35 | { 36 | Triangle(int d1,int d2) 37 | { 38 | super(d1,d2); 39 | } 40 | public double getArea() //compulsory overrinding 41 | { 42 | return 0.5*dim1*dim2; 43 | } 44 | } 45 | class Prog52 46 | { 47 | public static void main(String[] args) 48 | { 49 | Scanner sc = new Scanner(System.in); 50 | int d1,d2; 51 | System.out.println("Enter the number of shapes"); 52 | int n = sc.nextInt(); 53 | Shape arr[]=new Shape[n]; 54 | for(int i=0;i master, origin/master) 2 | Merge: 8e7328c 42fe48d 3 | Author: MakarandPundlik 4 | Date: Fri Jan 1 20:40:42 2021 +0530 5 | 6 | Merge branch 'master' of https://github.com/MakarandPundlik/Core-Java 7 | 8 | commit 8e7328c5915575dc195c9dbfa21280fb09468642 9 | Author: MakarandPundlik 10 | Date: Wed Dec 30 11:58:35 2020 +0530 11 | 12 | program with iostream 13 | 14 | commit 1d8c890e37e73048b82050b1275d40ca9349018f 15 | Author: MakarandPundlik 16 | Date: Wed Dec 30 11:27:52 2020 +0530 17 | 18 | added iostrean 19 | 20 | commit 42fe48dd89e6dba4ec3188270ad24da1304143bc 21 | Author: MakarandPundlik <65530539+MakarandPundlik@users.noreply.github.com> 22 | Date: Tue Dec 1 14:26:44 2020 +0530 23 | 24 | Update README.md 25 | 26 | commit ddde7b4e029988869ba03d98bbcfa91b6d194d49 27 | Author: MakarandPundlik <65530539+MakarandPundlik@users.noreply.github.com> 28 | Date: Tue Dec 1 14:26:09 2020 +0530 29 | 30 | Update README.md 31 | 32 | commit a5781e332ce1b645071fffbb45341d9b5b09347e 33 | Author: MakarandPundlik <65530539+MakarandPundlik@users.noreply.github.com> 34 | Date: Tue Dec 1 14:25:23 2020 +0530 35 | 36 | Update README.md 37 | 38 | commit 6524fbac7073779d511e8330a5fe9701f2e7eef7 39 | Author: MakarandPundlik 40 | Date: Tue Dec 1 14:23:40 2020 +0530 41 | 42 | some tricks 43 | 44 | commit 53a969ca1ed4e895a2a205b63612842034dec302 45 | Merge: 07edba6 573d0ae 46 | Author: MakarandPundlik 47 | Date: Tue Dec 1 14:18:59 2020 +0530 48 | 49 | Merge branch 'master' of https://github.com/MakarandPundlik/Core-Java 50 | 51 | commit 07edba64e3c1766a51c68acbd1490f1441feb2fb 52 | Author: MakarandPundlik 53 | Date: Tue Dec 1 14:18:37 2020 +0530 54 | 55 | some tips 56 | 57 | commit 573d0ae309f369e6bc9adf89f69061f821688ba5 58 | Author: MakarandPundlik <65530539+MakarandPundlik@users.noreply.github.com> 59 | Date: Mon Nov 30 11:13:47 2020 +0530 60 | 61 | Added String.valueOf() 62 | 63 | commit 02a5f67c962cf05441ca9c21048ca24b63e6f78e 64 | Author: MakarandPundlik <65530539+MakarandPundlik@users.noreply.github.com> 65 | Date: Wed Nov 11 11:52:55 2020 +0530 66 | 67 | Update README.md 68 | 69 | commit 3cb6e79e9ebb554c76d3cbb59f34636a02372f1a 70 | Author: MakarandPundlik <65530539+MakarandPundlik@users.noreply.github.com> 71 | Date: Wed Nov 11 11:28:31 2020 +0530 72 | 73 | Update README.md 74 | 75 | commit a353aeed87e3a6c75d51f534d80b9954ce866279 76 | Author: MakarandPundlik <65530539+MakarandPundlik@users.noreply.github.com> 77 | Date: Mon Nov 9 13:21:20 2020 +0530 78 | 79 | Update README.md 80 | 81 | commit 29e38cada638ae68c51d59161931dd8cbd1b4c54 82 | Author: MakarandPundlik <65530539+MakarandPundlik@users.noreply.github.com> 83 | Date: Mon Nov 9 13:20:33 2020 +0530 84 | 85 | initial readMe 86 | 87 | commit 76945f7bd95040815041169d529b0cb3f5f1a0e2 88 | Author: MakarandPundlik 89 | Date: Sun Nov 8 21:50:30 2020 +0530 90 | 91 | StringBuffer and Wrapper Class 92 | 93 | commit 41dc04754eb9eba2dd27d2727a2566c4b82b41a4 94 | Author: MakarandPundlik 95 | Date: Sat Nov 7 12:52:40 2020 +0530 96 | 97 | email validator 1 98 | 99 | commit 875ad56595dbde4af68e0a1a3f4fb49aa269f2aa 100 | Author: MakarandPundlik 101 | Date: Fri Nov 6 14:38:27 2020 +0530 102 | 103 | Programs on Strings 104 | 105 | commit d7393e93506997d2958e54050d8b43a4301561e0 106 | Author: MakarandPundlik 107 | Date: Thu Nov 5 22:46:08 2020 +0530 108 | 109 | :example of String class constructor 110 | 111 | commit 2c588883b1827e7ac8000a76a3f7ec7c36bc8286 112 | Author: MakarandPundlik 113 | Date: Thu Nov 5 22:40:54 2020 +0530 114 | 115 | concept of package 116 | 117 | commit e5d58b47e979e6caa660a166619ade35f9a77526 118 | Author: MakarandPundlik 119 | Date: Thu Nov 5 19:53:17 2020 +0530 120 | 121 | user defined exceptions 122 | 123 | commit 922ccdd1c26862afeb2d39e6cee64b12dd7665ee 124 | Author: MakarandPundlik 125 | Date: Wed Nov 4 22:06:04 2020 +0530 126 | 127 | exception handling 128 | 129 | commit b235abc9dec3d5f4a864a52008a192390a1d9f0d 130 | Author: MakarandPundlik 131 | Date: Wed Nov 4 21:46:58 2020 +0530 132 | 133 | toString() and interface 134 | 135 | commit d19318efbd5d647d8f87b76cf5c8757cdf7aa534 136 | Author: MakarandPundlik 137 | Date: Tue Nov 3 14:48:47 2020 +0530 138 | 139 | use of a final keyword 140 | 141 | commit f2f8335b27e53e06919d997cc35260a1139a3576 142 | Author: MakarandPundlik 143 | Date: Tue Nov 3 14:41:42 2020 +0530 144 | 145 | abstract class and methods 146 | 147 | commit 288682e27900e5b4fb8942c314a3be85d54da90a 148 | Author: MakarandPundlik 149 | Date: Sun Nov 1 15:38:11 2020 +0530 150 | 151 | method overriding 152 | 153 | commit 5edbacbba4b8222ffb49a991bd6897b9418b7f74 154 | Author: MakarandPundlik 155 | Date: Sat Oct 31 21:54:58 2020 +0530 156 | 157 | method overriding 158 | 159 | commit a4fe1bb2a478711f13dada0da8b7c8427b40fba8 160 | Author: MakarandPundlik 161 | Date: Sat Oct 31 19:59:32 2020 +0530 162 | 163 | completed overloading 164 | 165 | commit f8b614f3cfc78fd9e9bf6769f98265f99310b205 166 | Author: MakarandPundlik 167 | Date: Fri Oct 30 23:26:51 2020 +0530 168 | 169 | introduction to static keyword 170 | 171 | commit 78a6295e8f0f1313ebbd2876c0764195bfa34f00 172 | Author: MakarandPundlik 173 | Date: Wed Oct 28 20:15:38 2020 +0530 174 | 175 | started with OOP 176 | 177 | commit edfc1dd279713bfb22159be1d1f72de28e5405ea 178 | Author: MakarandPundlik 179 | Date: Mon Oct 26 20:16:03 2020 +0530 180 | 181 | started user defined methods 182 | 183 | commit 5ff2e9228b2c317e2a619e23f0661538dc46a60c 184 | Author: MakarandPundlik 185 | Date: Wed Oct 21 22:05:02 2020 +0530 186 | 187 | till commandline argument handling 188 | 189 | commit dae8ec7b32e1f7c3c00ca4e190e80ac9e59b0639 190 | Author: MakarandPundlik 191 | Date: Tue Oct 20 21:58:35 2020 +0530 192 | 193 | .. 194 | --------------------------------------------------------------------------------