├── Assertion.java ├── Av.java ├── Car.java ├── CarProg.java ├── CarUse1.java ├── DequeExample.java ├── Deserialization.class ├── Deserialization.java ├── Employee.class ├── Employee.java ├── FileDemo.class ├── FileDemo.java ├── Idea1.java ├── InputStream.class ├── InputStream.java ├── LambdaExpressionWithout.java ├── Main.java ├── OnlineTest.java ├── SerializationDemo.class ├── SerializationDemo.java ├── ShortExample$1.class ├── ShortExample.class ├── ShortExample.java ├── ShortSetExample.java ├── Student.class ├── Student.java ├── TestAnonymousInner.java ├── TestCollection.java ├── TestInterface4.java ├── TestInterfaceDefault.java ├── TestInterfaceStatic.java ├── TestMemberOuter1.java ├── TestMultipleCatch.java ├── TestOuter1.java ├── Testinterface3.java ├── ThreeNumbers.java ├── Voter.java ├── localInner1.java ├── serial.txt └── untitled.java /Assertion.java: -------------------------------------------------------------------------------- 1 | import java.util.Scanner; 2 | class Assertion { 3 | 4 | public static void main(String[] args) 5 | { 6 | Scanner scanner=new Scanner(System.in); 7 | System.out.println("Enter your Sallary"); 8 | int value= scanner.nextInt(); 9 | assert value>=500:"Not Valid"; 10 | System.out.println("Salary is\n"+value); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /Av.java: -------------------------------------------------------------------------------- 1 | interface printable { 2 | void print(); 3 | } 4 | class Av implements printable 5 | { 6 | public void print(){ 7 | System.out.println("HI PARVEZ"); 8 | 9 | } 10 | public static void main(String args[]) { 11 | Av obj = new Av(); 12 | obj.print(); 13 | 14 | } 15 | } -------------------------------------------------------------------------------- /Car.java: -------------------------------------------------------------------------------- 1 | import java.util.*; 2 | class Car 3 | { 4 | int fuel; 5 | static int mile=20; 6 | static in maxfuel=85; 7 | int max=21; 8 | 9 | public int addFuel(int ltr)throws FuelTankFull 10 | { 11 | System.out.println("\nTank Check"); 12 | throw new FuelTankFull("Tank is Full"); 13 | return ltr; 14 | } 15 | 16 | } -------------------------------------------------------------------------------- /CarProg.java: -------------------------------------------------------------------------------- 1 | class FuelTankFull extends Exception 2 | { 3 | } 4 | class NotSufficientFuel extends Exception 5 | { 6 | } 7 | class Car 8 | { 9 | int fuel; 10 | final int speed=20; 11 | final int maxfu=400; 12 | public void addFuel(int ltr) throws FuelTankFull,NotSufficientFuel 13 | { 14 | if(ltrdeque=new ArrayDeque(); 7 | deque.offer("arvind"); 8 | deque.offer("vimal"); 9 | deque.offer("mukul"); 10 | deque.add("jai"); 11 | deque.offerLast("parvez"); 12 | System.out.println("After offerfirst traversal....."); 13 | for(String s:deque) 14 | { 15 | System.out.println(s); 16 | } 17 | deque.pollFirst(); 18 | System.out.println("After pollLast()traversal.."); 19 | for(String s:deque) 20 | { 21 | System.out.println(s); 22 | } 23 | } 24 | } -------------------------------------------------------------------------------- /Deserialization.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/siraajul/Uni-Java/4dc8b291e999af3b890832a0a4415888c6e9b448/Deserialization.class -------------------------------------------------------------------------------- /Deserialization.java: -------------------------------------------------------------------------------- 1 | import java.io.*; 2 | public class Deserialization 3 | { 4 | public static void main(String args[]) 5 | { 6 | try 7 | { 8 | Student object2; 9 | FileInputStream fis = new FileInputStream("serial"); 10 | ObjectInputStream ois = new ObjectInputStream(fis); 11 | object2 = (Student)ois.readObject(); 12 | ois.close(); 13 | System.out.println("object2: " + object2); 14 | } 15 | catch(Exception e) 16 | { 17 | System.out.println("Exception during deserialization: " + e); 18 | System.exit(0); 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /Employee.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/siraajul/Uni-Java/4dc8b291e999af3b890832a0a4415888c6e9b448/Employee.class -------------------------------------------------------------------------------- /Employee.java: -------------------------------------------------------------------------------- 1 | class Employee{ 2 | String name; 3 | String id; 4 | public Employee(String name,String id) 5 | { 6 | this.name=name; this.id=id; 7 | } 8 | public String toString() 9 | { 10 | return "Employee{"+"name="+name+",id="+id+"}; 11 | } 12 | } -------------------------------------------------------------------------------- /FileDemo.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/siraajul/Uni-Java/4dc8b291e999af3b890832a0a4415888c6e9b448/FileDemo.class -------------------------------------------------------------------------------- /FileDemo.java: -------------------------------------------------------------------------------- 1 | import java.io.File; 2 | class FileDemo{ 3 | public static void main(String args[]){ 4 | File f1 = new File("javaFile123.txt"); 5 | System.out.println("File Name:" + f1.getName()); 6 | System.out.println("Path:" + f1.getPath()); 7 | System.out.println("Abs Path:" + f1.getAbsolutePath()); 8 | System.out.println("Parent:" + f1.getParent()); 9 | System.out.println(f1.exists()? "exists" : "does not exist"); 10 | System.out.println(f1.canWrite() ? "is writable" : "is not writable"); 11 | System.out.println(f1.canRead() ? "is readable" : "is not Readable"); 12 | System.out.println("is" + (f1.isDirectory() ? "" : "not" + "a directory")); 13 | System.out.println(f1.isFile() ? "is normal File" : "might be named pipe"); 14 | System.out.println(f1.isAbsolute() ? "is absolute" : "is not absolute"); 15 | System.out.println("File last modified:" + f1.lastModified()); 16 | System.out.println("File size:" + f1.length() + "Bytes"); 17 | }} -------------------------------------------------------------------------------- /Idea1.java: -------------------------------------------------------------------------------- 1 | 2 | public class Idea1 { 3 | 4 | public static void main(String[] args) { 5 | // TODO Auto-generated method stub 6 | 7 | } 8 | 9 | } 10 | -------------------------------------------------------------------------------- /InputStream.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/siraajul/Uni-Java/4dc8b291e999af3b890832a0a4415888c6e9b448/InputStream.class -------------------------------------------------------------------------------- /InputStream.java: -------------------------------------------------------------------------------- 1 | import java.io.*; 2 | public class InputStream { 3 | public static void main(String arg s[]) throws IOException{ 4 | FileInputStream fis = null; 5 | int i=0; 6 | char c; 7 | try 8 | { 9 | fis = new FileInputStream("test.txt"); 10 | while((i=fis.read())!=-1) 11 | { 12 | c=(char)i; 13 | System.out.print(c); 14 | } 15 | } 16 | 17 | catch(FileNotFoundException ex) { 18 | System.out.println("File not found");} 19 | finally{if(fis!=null) 20 | fis.close(); 21 | } 22 | } 23 | } 24 | 25 | -------------------------------------------------------------------------------- /LambdaExpressionWithout.java: -------------------------------------------------------------------------------- 1 | interface Drawable{ 2 | public void draw(); 3 | } 4 | public class LambdaExpressionWithout { 5 | public static void main(String[] args) { 6 | int width=10; 7 | Drawable d=new Drawable(){ 8 | public void draw(){System.out.println("Drawing "+width);} 9 | }; 10 | d.draw(); 11 | } 12 | } -------------------------------------------------------------------------------- /Main.java: -------------------------------------------------------------------------------- 1 | class IPL 2 | { 3 | String name,wck alrnd,cpt; 4 | IPL(String name,String wicket,String allround,String captain); 5 | { 6 | name=names; 7 | wck=wicket; 8 | alrnd=allround; 9 | cpt=captain; 10 | } 11 | private Player 12 | { 13 | String pname; 14 | Integer price; 15 | Player(String playername,Integer pricee); 16 | { 17 | pname=playername; 18 | price=pricee; 19 | } 20 | } 21 | Player obj4=new Player("Vicky",120000); 22 | Player obj5=new Player("Vikash",150000); 23 | Player obj6=new Player("Varun",90000); 24 | public void display() 25 | { 26 | System.out.println(name+"\t"+wck+"t"+alrnd+"\t"+cpt+"\t"); 27 | 28 | } 29 | class main 30 | { 31 | public static void main(String[] args) 32 | { 33 | TreeSet ts= new TreeSet((x,y)->y.price.compareTo(x.price)); 34 | IPL obj1=new IPL("Sakib","Dhoni","Umesh","Rahul"); 35 | IPL obj2=new IPL("Koli","Fizz","Mash","Tamim"); 36 | IPL obj3=new IPL("Mushi","Rubel","Kartik","Ashraful"); 37 | ts.add(obj1);ts.add(obj2);ts.add(obj3); 38 | 39 | Iterator i=ts.iterator(); 40 | while(i.hasNext()) 41 | { 42 | IPL t=i.next(); 43 | t.display(); 44 | break; 45 | } 46 | 47 | 48 | } 49 | } 50 | } -------------------------------------------------------------------------------- /OnlineTest.java: -------------------------------------------------------------------------------- 1 | import java.awt.*; 2 | import java.awt.event.*; 3 | import javax.swing.*; 4 | 5 | class OnlineTest extends JFrame implements ActionListener 6 | { 7 | JLabel l; 8 | JRadioButton jb[]=new JRadioButton[5]; 9 | JButton b1,b2; 10 | ButtonGroup bg; 11 | int count=0,current=0,x=1,y=1,now=0; 12 | int m[]=new int[10]; 13 | OnlineTest(String s) 14 | { 15 | super(s); 16 | l=new JLabel(); 17 | add(l); 18 | bg=new ButtonGroup(); 19 | for(int i=0;i<5;i++) 20 | { 21 | jb[i]=new JRadioButton(); 22 | add(jb[i]); 23 | bg.add(jb[i]); 24 | } 25 | b1=new JButton("Next"); 26 | b2=new JButton("Bookmark"); 27 | b1.addActionListener(this); 28 | b2.addActionListener(this); 29 | add(b1);add(b2); 30 | set(); 31 | l.setBounds(30,40,450,20); 32 | jb[0].setBounds(50,80,100,20); 33 | jb[1].setBounds(50,110,100,20); 34 | jb[2].setBounds(50,140,100,20); 35 | jb[3].setBounds(50,170,100,20); 36 | b1.setBounds(100,240,100,30); 37 | b2.setBounds(270,240,100,30); 38 | setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 39 | setLayout(null); 40 | setLocation(250,100); 41 | setVisible(true); 42 | setSize(600,350); 43 | } 44 | public void actionPerformed(ActionEvent e) 45 | { 46 | if(e.getSource()==b1) 47 | { 48 | if(check()) 49 | count=count+1; 50 | current++; 51 | set(); 52 | if(current==9) 53 | { 54 | b1.setEnabled(false); 55 | b2.setText("Result"); 56 | } 57 | } 58 | if(e.getActionCommand().equals("Bookmark")) 59 | { 60 | JButton bk=new JButton("Bookmark"+x); 61 | bk.setBounds(480,20+30*x,100,30); 62 | add(bk); 63 | bk.addActionListener(this); 64 | m[x]=current; 65 | x++; 66 | current++; 67 | set(); 68 | if(current==9) 69 | b2.setText("Result"); 70 | setVisible(false); 71 | setVisible(true); 72 | } 73 | for(int i=0,y=1;itree=new TreeSet(new Comparator() 7 | { 8 | public int compare(Integer o1, Integer o2) 9 | { 10 | return o2.compareTo(o1); 11 | 12 | } 13 | }); 14 | tree.add(1); 15 | tree.add(1); 16 | tree.add(1); 17 | System.out.println("TreeSet"+tree); 18 | 19 | 20 | } 21 | } -------------------------------------------------------------------------------- /ShortSetExample.java: -------------------------------------------------------------------------------- 1 | import java.util.*; 2 | public class ShortSetExample 3 | { 4 | public static void main(String...a) 5 | { 6 | Employee emp1=new Employee("cse","4"); 7 | Employee emp2=new Employee("eee","5"); 8 | Employee emp3=new Employee("mec","7"); 9 | SettreeSet=new Treeset(new Comparator() 10 | { 11 | public int compare(Employee o1,Employee o2) 12 | { 13 | return o1.name.compareTo(o2.name); 14 | } 15 | }); 16 | treeSet.add(emp1); 17 | treeSet.add(emp2); 18 | treeSet.add(emp3); 19 | System.out.println("treeSet:"+treeSet); 20 | } 21 | } -------------------------------------------------------------------------------- /Student.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/siraajul/Uni-Java/4dc8b291e999af3b890832a0a4415888c6e9b448/Student.class -------------------------------------------------------------------------------- /Student.java: -------------------------------------------------------------------------------- 1 | import java.io.*; 2 | class Student implements Serializable 3 | { 4 | String name; 5 | int id; 6 | double d; 7 | public Student(String name,int id,double d){ 8 | this.name=name; 9 | this.id=id; 10 | this.d=d; 11 | } 12 | public String toString() 13 | { 14 | return "name="+name+";id="+id+";d="+d; 15 | } 16 | } -------------------------------------------------------------------------------- /TestAnonymousInner.java: -------------------------------------------------------------------------------- 1 | abstract class Person 2 | { 3 | abstract void eat(); 4 | } 5 | class TestAnonymousInner 6 | { 7 | public static void main(String[] args) { 8 | Person p= new Person() 9 | { 10 | void eat(){System.out.println("nice food");} 11 | }; 12 | p.eat(); 13 | } 14 | } -------------------------------------------------------------------------------- /TestCollection.java: -------------------------------------------------------------------------------- 1 | import java.util.*; 2 | public class TestCollection 3 | { 4 | public static void main(String[] args) 5 | { 6 | ArrayListal=new ArrayList(); 7 | al.add("Kalyan"); 8 | al.add("Ajay"); 9 | al.add("Vishal"); 10 | al.add(I,"Parvez"); 11 | System.out.println("element 2nd position"+al.get(2)); 12 | ListIteratoritr=al.ListIterator(); 13 | System.out.println("traversing elements in forward direction.."); 14 | while(itr.hasNext()) 15 | { 16 | System.out.println(itr.next()); 17 | } 18 | System.out.println(itr.next); 19 | } 20 | System.out.println("traversing elements in backward direction..."); 21 | while (itr.hasPrevious()) 22 | { 23 | System.out.println(itr.previous()); 24 | } 25 | } -------------------------------------------------------------------------------- /TestInterface4.java: -------------------------------------------------------------------------------- 1 | interface printable 2 | { 3 | void print(); 4 | } 5 | interface Showable extends printable 6 | { 7 | void show(); 8 | } 9 | class TestInterface4 implements Showable 10 | { 11 | public void print(){System.out.println("Bangladeshi");} 12 | public void show(){System.out.println("Non-veg");} 13 | public static void main(String[] args) { 14 | TestInterface4 obj=new TestInterface4(); 15 | obj.print(); 16 | obj.show(); 17 | } 18 | } -------------------------------------------------------------------------------- /TestInterfaceDefault.java: -------------------------------------------------------------------------------- 1 | interface Drawable 2 | { 3 | void draw(); 4 | default void msg(){System.out.println("General Method");} 5 | } 6 | class Circle implements Drawable{ 7 | public void draw(){System.out.println("Drawing Circle");} 8 | } 9 | class TestInterfaceDefault{ 10 | public static void main(String[] args) { 11 | Drawable d=new Circle(); 12 | d.draw(); 13 | d.msg(); 14 | } 15 | } -------------------------------------------------------------------------------- /TestInterfaceStatic.java: -------------------------------------------------------------------------------- 1 | interface Drawables 2 | { 3 | void draw(); 4 | static int cube(int h){return h*h*h;} 5 | } 6 | class Circles implements Drawables 7 | { 8 | public void draw(){System.out.println("Drawing Circle");} 9 | } 10 | class TestInterfaceStatic{ 11 | { 12 | Drawables d=new Circles(); 13 | d.draw(); 14 | System.out.println(Drawables.cube(3)); 15 | } 16 | } -------------------------------------------------------------------------------- /TestMemberOuter1.java: -------------------------------------------------------------------------------- 1 | class TestMemberOuter1 2 | { 3 | private int data=344; 4 | class Inner 5 | { 6 | void msg() {System.out.println("Data is "+data);} 7 | } 8 | public static void main(String args[]) 9 | { 10 | TestMemberOuter1 obj=new TestMemberOuter1(); 11 | TestMemberOuter1.Inner in=obj.new Inner(); 12 | in.msg(); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /TestMultipleCatch.java: -------------------------------------------------------------------------------- 1 | public class TestMultipleCatch{ 2 | 3 | public static void main(String args[]) 4 | { 5 | try 6 | { 7 | int a[]=new int[5]; 8 | a[5]=30/0; 9 | } 10 | catch(ArithmeticException e) 11 | { 12 | System.out.println("task1 is completed"); 13 | } 14 | catch(ArrayIndexOutOfBoundsException e) 15 | { 16 | System.out.println("task 2 completed"); 17 | } 18 | catch(Exception e) 19 | { 20 | System.out.println("common task completed"); 21 | } 22 | 23 | System.out.println("rest of the code..."); 24 | } 25 | } -------------------------------------------------------------------------------- /TestOuter1.java: -------------------------------------------------------------------------------- 1 | class TestOuter1 2 | { 3 | static int data=30; 4 | static class Inner 5 | { 6 | void msg(){System.out.println("data is "+data);} 7 | } 8 | public static void main(String[] args) 9 | { 10 | TestOuter1.Inner obj=new TestOuter1.Inner(); 11 | obj.msg(); 12 | } 13 | } -------------------------------------------------------------------------------- /Testinterface3.java: -------------------------------------------------------------------------------- 1 | interface printable 2 | { 3 | void print(); 4 | } 5 | interface Showable 6 | { 7 | void print(); 8 | } 9 | class Testinterface3 implements printable, Showable 10 | { 11 | public void print(){System.out.println("Hello Vishal");} 12 | public static void main(String[] args) 13 | { 14 | Testinterface3 obj=new Testinterface3(); 15 | obj.print(); 16 | } 17 | } -------------------------------------------------------------------------------- /ThreeNumbers.java: -------------------------------------------------------------------------------- 1 | import java.util.Scanner; 2 | public class ThreeNumbers 3 | { 4 | public static void main(String args[]) 5 | { 6 | Scanner scanner=new Scanner(System.in); 7 | 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /Voter.java: -------------------------------------------------------------------------------- 1 | class Voter 2 | { 3 | string name; 4 | string dob; 5 | int id; 6 | int age; 7 | Voter(string name, string dob, int id,int age) 8 | { 9 | { 10 | name = names; 11 | dob = dobs; 12 | age = ages; 13 | if(age = 18) 14 | { 15 | id >= ids; 16 | } 17 | } 18 | class Voter_Card 19 | { 20 | boolean status; 21 | String votername; 22 | int voterid; 23 | Voter_Card(String voternames , int votersid , boolean statuss) 24 | { 25 | votername = voternames ; 26 | voterid = votersid ; 27 | status = statuss; 28 | } 29 | } 30 | } 31 | public void display() 32 | { 33 | System.out.println(votername+ "\t" + voterid +"\t"+dob+"\t"+age+"\t"+status+"\t"); 34 | } 35 | } 36 | class main 37 | { 38 | public static void main(String...rtk) 39 | { 40 | Treeset ts = new Treeset(); 41 | Voter obj = new Voter("Raj" , "04/04/1998" , 11605461 , 18); 42 | Voter obj1 = new Voter("Srinjay" , "05/06/1999" , 11605641 , 17); 43 | Voter obj2 = new Voter("Dam" , "06/05/1997" , 11605879 , 19); 44 | ts.add(obj) ; ts. add(obj1) ; ts.add(obj2); 45 | Iterator i = new iterator(); 46 | int a=2; 47 | while(i.hasNext()) 48 | { 49 | Voter e = e.next(); 50 | if(e.age >= 18) 51 | { 52 | namess = e.name; 53 | idss = e.id; 54 | Voter.Voter_Card obj4 = new Voter.Voter_Card(namess , idss, true); 55 | } 56 | e.display(); 57 | } 58 | } 59 | } -------------------------------------------------------------------------------- /localInner1.java: -------------------------------------------------------------------------------- 1 | public class localInner1 2 | { 3 | private int data=431; 4 | void display(){ 5 | class Local 6 | { 7 | void msg(){System.out.println(data);} 8 | } 9 | Local l=new Local(); 10 | l.msg(); 11 | } 12 | public static void main(String[] args) { 13 | localInner1 obj=new localInner1(); 14 | obj.display(); 15 | } 16 | } -------------------------------------------------------------------------------- /serial.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/siraajul/Uni-Java/4dc8b291e999af3b890832a0a4415888c6e9b448/serial.txt -------------------------------------------------------------------------------- /untitled.java: -------------------------------------------------------------------------------- 1 | import java.io.*; 2 | class Student implements Serializable 3 | { 4 | String name; 5 | int id; 6 | double d; 7 | public Student(St name,int id,double d){ 8 | this.name=name; 9 | this.id=id; 10 | this.d=d; 11 | } 12 | public String toString() 13 | { 14 | return "name"=+name+";id"=+id+"d"=+d; 15 | } 16 | } --------------------------------------------------------------------------------