Pages

Tamil Nadu Teacher Eligibility Test 2013

know your Roll Number Click here

வைரஸ் தாக்கிய ‘பென்ட்ரைவ்’ இலிருந்து பைல்களை மீட்க சிம்பிள் வழி!






வைரஸ் தாக்கியபென்ட்ரைவ்இலிருந்து பைல்களை மீட்க சிம்பிள் வழி!

தற்பொழுது தகவல்களை சேமிக்க பெரும்பாலானவர்களால் பயன்படுத்தப்படுவது USB பென்டிரைவ்கள். இதில் முக்கியமான பிரச்சினை வைரஸ் பிரச்சினை. வெவ்வேறான கணனிகளில் உபயோகிப்பதால் வைரஸ்கள் சுலபமாக பென்டிரைவில் புகுந்து உள்ளே இருக்கும்பைல்களை பாதிக்கிறது.
இப்படி பாதிக்கும் பொழுதுஉங்கள் பென்ட்ரைவில் உள்ளபைல்கள் மறைக்கப்பட்டுவிடும் கணனியில் பென்டிரைவை ஓப்பன் செய்தால் எந்த பைல்களும் இருக்காது. வெற்றிடமாக இருக்கும். ஆனால் properties சென்று பார்த்தால் பைல்கள் இருப்பது போன்றே அளவு காட்டும். காரணம் நம் தகவல்களை வைரஸ்கள் மறைத்து வைத்துவிட்டது. பென்டிரைவில் முக்கியமான தவல்கள் ஏதும் இல்லை எனில் Format செய்து பென்டிரைவை திரும்ப பெறலாம். ஆனால் ஏதேனும் முக்கிய மான தகவல்கள் இருந்தால் எப்படி அந்த பைல்களை பத்திரமாக மீண்டும் கொண்டு வருவது என பார்ப்போம்.

இதற்க்கு நீங்கள் எந்த மென்பொருளையும் உங்கள் கணினியில் Install செய்து உபயோகிக்க வேண்டியதில்லை.உங்கள் கணனியிலேயே சுலபமாக செய்து விடலாம். கீழே உள்ள வழிமுறையின் படி கவனமாக செய்து அந்த பைல்களை மீட்டு எடுங்கள்.

1) முதலில் பென்டிரைவை உங்கள் கணினியில் சொருகி கொள்ளுங்கள்.

2) Start ==> Run ==> CMD==> Enter கொடுக்கவும்.

3) இப்பொழுது பென்ட்ரைவ் எந்த ட்ரைவில் உள்ளது என பாருங்கள். My Computer செல்வதன் மூலம் கண்டறியலாம்.

4) உதாரணமாக E: டிரைவில் பென்ட்ரைவ் இருக்கிறது எனவைத்து கொள்வோம் அதற்கு நீங்கள் E: என கொடுத்து Enter அழுத்தவும்.

5) attrib -h -s -r /s /d *.*என டைப் செய்யுங்கள் ஒவ்வொருபகுதிக்கும் Space சரியாககொடுக்கவும்.

நீங்கள் சரியாக கொடுத்துஉள்ளீர்கள் என உறுதி செய்து கொண்டு Enter அழுத்துங்கள்.

சில வினாடிகள் பொறுத்திருங்கள். இப்பொழுது உங்கள் பென்ட்ரைவ் சோதித்து பாருங்கள் உங்களுடைய பைல்கள் அனைத்தும் திரும்பவும் வந்திருக்கும்

Srinivasan Profile


C.Seenivasn Profile Click Here

kochadaiyaan The Legend - Official Trailer Rajinikanth

Java Collections Deep Concept





Java.util package

This package contains a lot of utility classes for working with various data structures.
It also contains other classes like Date, Calendar, Locale etc
This is one of the vast packages (other vast packages are javax.swing , java.awt and related packages )



Collection.

A collection is a group of objects
Operations that can be performed on an collection

(i) adding new object into the collection
(ii)removing existing objects
(iii)modify existing objects
(iv)view all objects


Types of collections

Lists, Sets, Maps //interface

(i)Lists.
  These collections permit duplicate objects into the collection



(ii)Sets.
   These collections do not permit duplicate objects


(iii)Maps
   These collections store objects in terms of a key/value pair



Collection Framework.

A framework is a set of classes and interfaces
Collection framework
It is a set of collection classes and interfaces 


**java's collection framework is a part of "java.util" package


(i)the "java.util.Collection" interface
This interface is at the top of the collection framework. It has two child interfaces "java.util.List" and "java.util.Set"

(ii) the "java.util.List" interface.
  this interface and its classes are used to work with "List" model of collection


(iii) the "java.util.Set" interface
this interface and its classes are used to work with "Set" model of collection
few methods of "Collection" interface


(i) add(Object ob)
(ii)remove(Object ob)
(iii)iterator()
(iv)toArray()
(v)size()
(vi)isEmpty()



ArrayList
 
The "java.util.ArrayList" class

This class implements the "java.util.List" interface

This class is used to work with dynamic arrays.

Insertions into ArrayList are slower.
Retrievals and deletions from ArrayList are faster
ArrayList is used when data amount is known in advance,i.e when there are less no of insertions

import java.util.*;
class ArrayListDemo
{
    public static void main(String args[])
    {
        ArrayList al = new ArrayList();

        al.add("java");
        al.add("programming");
        al.add("java");
        al.add("programming");
        System.out.println(al);
    }
}




LinkedList
 
The "java.util.LinkedList" class

This class implements the "java.util.List" interface

This class is used for working with DOUBLY LINKED LISTS

Insertions into the LinkedList are faster
Retreivals and deletions are slower  
Linkedlist is used when there are many insertions

Ex:
import java.util.*;
class LinkedListDemo
{
    public static void main(String args[])
    {
        LinkedList al = new LinkedList();

        al.add("java");
        al.add("programming");
        al.add("java");
        al.add("programming");
        System.out.println(al);
        al.remove("java");
        al.remove("programming");
        System.out.println(al);

        int size = al.size();
        boolean b = al.isEmpty();
        System.out.println(size+":"+b);
        al.clear();
        size = al.size();
        b = al.isEmpty();
        System.out.println(size+":"+b);
    }
}



TreeSet

The "java.util.TreeSet"  class

This class implements the  "java.util.Set" interface

This is used to work with binary tree

import java.util.*;
class TreeSetDemo
{
    public static void main(String args[])
    {
        TreeSet al = new TreeSet();    
        al.add("java");
        al.add("programming");
        al.add("java");
        al.add("programming");
        System.out.println(al);
    }
}


Elements in TreeSet are automatically Sorted because "TreeSet" implements "SortedSet" interface which is a child of "Set" interface


HashSet

The "java.util.HashSet" class

This class implements "Set" interface

This class is used in working with hashing
Elements in "HashSet" are NOT SORTED and also NOT PLACED ACCORDING TO add() sequence, i.e elements in HashSet ARE NOT ORDERED

import java.util.*;
class HashSetDemo
{
    public static void main(String args[])
    {
        HashSet al = new HashSet();    
        al.add("A");
        al.add("B");
        al.add("C");
        al.add("D");
        System.out.println(al);
    }
}



Iterator

The "java.util.Iterator" interface
This interface contains the methods that are used to loop across the objects in a collection
This interface and its methods are available to all the children of "java.util.Collection" interface
 
Its methods are

    boolean  hasNext()
    Object   next()
    void     remove()

Getting a reference to "Iterator" interface
this is done by "iterator()" method of the "Collection" inteface

    Iterator iterator()
     Iterator itr= ll.iterator();
       Object ob= itr.next();
    String s = (String) ob;

import java.util.*;
class LinkedListDemo
{
    public static void main(String args[])
    {
        LinkedList al = new LinkedList();

        al.add("java");
        al.add("programming");
        al.add("java");
        al.add("programming");

        Iterator  itr = al.iterator();
        while(itr.hasNext())
        {
            String s = (String) itr.next();

            System.out.println(s.toUpperCase()); 
        }     
    }
}


Storing user defined objects in a collection

import java.util.*;
class Student
{
    int studentNo;
    Address a1;
    Student(int studentNo, Address a1)
    {
        this.studentNo = studentNo;
        this.a1 = a1;
    }
    void printStudent()
    {
        System.out.println("Student No : " +studentNo);
    }     


}

class Test
{
    public static void main(String args[])
    {
        LinkedList ll = new LinkedList();

        ll.add(new Student(30, new Address()));
        ll.add(new Student(10));
        ll.add(new Student(20));

        Iterator itr = ll.iterator();
        while(itr.hasNext())
        {
            Student temp = (Student) itr.next();
            temp.printStudent();

        }
    }
}



HashMap


The "java.util.HashMap" class
This class implements the "AbstractMap" interface
This class is used to work with collections which store objects in the form of key and value pairs
few methods of this class
    void put(Object key,Object value)
    Object get(Object key)
    Set  keySet()

import java.util.*;
class HashMapDemo
{
    public static void main(String args[])
    {
        HashMap hm = new HashMap();

        hm.put("tn","chennai");
        hm.put("mh","mumbai");
        hm.put("wb","kolkatta");
        hm.put("ap","hyderabad");


        Set s = hm.keySet();
        Iterator itr = s.iterator();
        while(itr.hasNext())
        {
            String s1 = (String)itr.next();
            String s2=(String)hm.get(s1);
            System.out.println(s1+":"+s2);
        } 
    }
}




TreeMap


The "java.util.TreeMap" class
This class implements the "SortedMap" interface
This works in the same way as "HashMap" but the elements are sorted automatically



Vector


The "java.util.Vector" class
This class same as "ArrayList", but its methods are synchronized



Enumeration


The "java.util.Enumeration" interface
This interface is same as "Iterator", but it is used with "Vector" class
its methods are
(i)    boolean hasMoreElements()
(ii)   Object nextElement()

 
import java.util.*;
class VectorDemo
{
    public static void main(String args[])
    {
        Vector v = new Vector();
        v.add("b");
        v.add("a");
        v.add("c");

        Enumeration e = v.elements();
        //(Iterator itr = al.iterator() )
        while(e.hasMoreElements() ) 
        {
            String s = (String) e.nextElement();
            System.out.println(s.toUpperCase() );
        } 
    }
}




Collections
The "java.util.Collections" class
It is a utility class which contains numerous number of static methods for different uses
Ex.
     Collections.sort(Il);
Assuming that "ll" is an object of "LinkedList" or "ArrayList" , the sort() method of "Collections" class sorts the objects of the "ll"


Arrays


The "java.util.Arrays" class
This is same like "Collections" but used for working with various operations on arrays like searching for an element in an array
the "java.util.Hashtable" class ('t' small letter)

This works in the same way as "HashMap" but the methods of this class are synchronized and "HashMap" methods are NOT SYNCHRONIZED the "java.util.StringTokenizer" class
This class is used to split a string into different words (tokens)
its methods are
    boolean hasMoreTokens()
    String nextToken()

The programming style of this class is same as "Enumeration"
Generics

A generic is a collection that supports storage of homogenous elements in a collection
Generics are introduced in JDK1.5

Syntax
 
  LinkedList<String> ll = new                 LinkedList<String>();


Enhanced for loop.
This loop is used to loop across the generics
Syntax cum example
    for(String s: ll)
    Sop(s.toUpperCase() )

HashMap<String,String> hm = new HashMap<String,String>();


Autoboxing.

It is a feature where we can add primitives to a collection. then they are automatically converted (boxed ) into its equivalent wrapper class type
   Ex.
   

    LinkedList ll = new LinkedList();
    ll.add(10); //error upto JDK1.4

    ll.add(10); // correct from JDK 1.5
                 // AUTO BOXING TAKES PLACE

Additional classes from "java.util" package which may be used on need basis
(i) Queue
(ii)PriorityQueue
(iii)Stack
(iv)LinkedHashMap
(v)WeakHashMap



Date

The  "java.util.Date" class
This class is used to work with system date
Ex.
import java.util.*;
class DateDemo
{
    p s  v m (String args[])
    {
        Date d  = new Date();
        Sop(d);
    }
}

Java Inner class and outer class





1)Inner class (also called nested class)
   A class that is defined inside another class is  called inner class (nested class).
   Inner classes are of different types


2)Non static inner class. A class that is defined inside other class and outside any method of that class without the use of static keyword is called non static inner class.

Eg   class A { 
class B{  }
}

3)When we compile a program that contains an outerclass and innerclass definition, a separate .class file will be generated for the inner class

4)non static inner classes are accessed only using the instance of its enclosing class.

5)A non static inner class can directly access the members (including private members) of its enclosing class

Eg.     
class A{
        private int i;
        class B{ 
            void m1(){
                System.out.println(i); // note i belongs to outerclass             }
        } 

    }

6)Creating an instance/object of a non static inner class from within the method(s) of its enclosing class (outer class)
  

class A{
        int i;

        void m1(){
            B b1 = new B();
            b1.m2();
        }

        class B{  void m2(){  System.out.println(i);
        }
        }
    }

 
    
7)Creating an instance/object of a non static inner class from outside the outerclass

  
 
class A{
        int i;

        void m1(){                    }
        class B{  void m2(){  System.out.println(i);
        }
        }

        public static void main(String args[])
        {
            A a1 = new A();
            A.B  b1=  a1.new B();

            b1.m2();
        }
    }

  
 
8) The following modifiers can be applied to declare an inner class
  
 final    abstract   public  private   protected  static  

1) Static inner class (also called static nested class)
A static inner class is an inner class that is defined inside the body of another class using the keyword static

class A {  
        static class B { void m1(){

        }
        }   }


2) Creating the instance/object of static nested class

A.B b1 = new A.B();
   b1.m1();


 

1)Local class (method local innerclass)
  A class that is defined inside a method is called local class or method local inner class

Eg
class A
    {
        int i;
        void m1()
        {
            class B
            {
                void m2()
                {
                    System.out.println(i);
                } // close local class method
            }  // close inner class
        } // close outer class method
    }


   class Test1
    {
        public static void main(String args[])
        {
            A a1 = new A();
            a1.m1();
        }
    }



2) A method local inner class can only be instantiated from the method in which it is   defined  ( meaning it cannot be instantiated from out side the method in which defined)

3) A method local inner class cannot be declared public, private, protected,static  and transient

4) A  method local inner class can be declared abstract or final

1) Anonymous inner class
   An inner class that is defined without a name is called anonymous inner class
 
2)Anonymous inner class can be declared with in a method or as an argument in a method


eg1
package cre;
public class Simplee {
    class A
    {
        public void m1()
        {
            System.out.println("inside m1");
        }
    }

    class B
    {

        A a1 = new A() { public void m1() { System.out.println("inside m1 of anonymous"); } };
        void m2()
        {
            a1.m1();
        }   

    }
    class Test
    {
        public static void main(String args[])
        {
            B b1 = new B();
            b1.m2();
        }
   }

}

The object reference "a1" does not refer to an instance of A, but to the instance of un named (anonymous) sub class of A.

3) Defining an anonmous inner class inside the argument of a method

 Ex
interface A { void m1();  }
class B {  void m2(A a){  } }
class C
{
    void m3()
    {
        B b1 = new B();
        b1.m2(new A(){ void m1(){ System.out.println("method m1"); } } );

    }
}

class Test
{
    public static void main(String args[])
    {
        C c1 = new C();
        c1.m3();
    }

}

Java.IO Package input stream and output stream Deep Concept





This package contains the input/output facilities (i.e classes) that are used to read input or write output

Stream


A stream is a collection of memory cells.

A stream is connected to a data source or a device like  a file, keyboard, network computer, monitor, printer

A stream is the mediator between the datasource/device   and a program, i.e the program reads data from the stream or the program writes the data to the stream.

Stream



Inputstream.


The stream from which the program reads the data is called inputstream



Outputstream.


The stream to which the program writes data is called outputstream
Streams in java.


Streams in java are objects of the relevant stream classes.



For example


BufferedInputStream is a stream class
BufferedOutputStream is a stream class
BufferedInputStream bis;
BufferedOutputStream bout; 

bis and bout are objects (stream objects).
All stream classes are a part of "java.io" package



Types of streams

There are two types
(i) Byte streams
(ii)Character streams


Byte streams are used to read and write binary data (8 bits data)

Character streams are used to read and write character data (supports reading and writing 16 bits character data)
The super classes of Byte stream category

InputStream  and  OutputStream

The super classes of character stream category

Reader  and Writer
few class names
BufferedReader
BufferedWriter
FileReader 
FileWriter
BufferedInputStream 
FileInputStream
FileOutputStream


The input stream "System.in" is connected to k/b.

the "InputStreamReader" class. Object of this class is used convert bytes to characters.
the "BufferedReader" class. This is the subclass of "Reader" used to read from buffer.


Presentation11

the "read()" method .
This method is a member of "InputStream" and "Reader" classes.
This is used to read one character from the stream  and return an int.
This method throws IOException

when the end of stream is reached this method returns -1

Example
import java.io.*;
    class ReadDemo
    {  
        public static void main(String args[]) throws Exception
        {  

            BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
            System.out.println("Enter few characters (CTRL-C to stop)");
            int i=0;
            do
            {
                i = br.read();
                if(i != -1)  
                    Sop((char)i);
            } while(i != -1);

        }
    }
   

Example
import java.io.*;
    class ReadLineDemo
    {  
        public static void main(String args[]) throws Exception
        {  

            BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
            int num1=0,num2=0;
            String temp="";
            System.out.println("Enter first number");
            temp = br.readLine();

            num1 = Integer.parseInt(temp);
            System.out.println("Enter other number");
            temp = br.readLine();

            num2 = Integer.parseInt(temp);
            Sop(num1+num2);

            System.out.println("Enter few characters (CTRL-C to stop)");
            int i=0;
            do
            {
                i = br.read();
                if(i != -1)  
                    Sop((char)i);
            } while(i != -1);

        }
    }


The "FileInputStream" and "FileOutputStream" classes

These are used in working with files.
import java.io.*;
class FileCopy
{
    public static void main(String args[]) throws Exception
    {

        FileInputStream in = new FileInputStream("test.txt");
        FileOutputStream out = new FileOutputStream("test2.txt");
        int i=0;
        do
        {
            i = in.read();
            if(i != -1)
                out.write(i);
        } while(i!=-1);
        System.out.println("file copied...");
    }
}
}


The  "DataInputStream" and "DataOutputStream" classes
These are used to read and write primitive data types like int, char and  float etc
DataInputStream class contains methods like readInt(),readByte()  etc for reading int s , byte s
DataOutputStream class contains methods like writeInt(), writeByte() etc for writing int s, byte s import java.io.*;

class DIS
    {
        public static void main(String args[]) throws Exception
        {
            DataInputStream in = new DataInputStream(System.in);

            DataOutputStream  out = new DataOutputStream(System.out);
            System.out.println("Enter a number ");
            int x= in.readInt();
            out.writeInt(x);
        }
    }


Object's state.
An object's state is the data of instance variables of an object

For example
Student s1 = new Student();
   s1.sno=10;
   s1.sname="srini";

the values of "sno" and "sname"  (10 and srini) of "s1" are together called as object's state

Serialization.

It is the process of saving an object's state to a storage
The "java.io.Serializable" interface
This interface has no methods. interfaces which contain no methods are called marker interfaces.
only objects those classes which implement "Serializable" interface can be serialized



the "java.io.ObjectInputStream" class and "java.io.ObjectOutputStream" class
These classes contain the methods used to read a serialized object and write an object's state toa storage

Example.

ObjectOutputStream out = new ObjectOutputStream(new FileOutputStream("student.ser"));
ObjectInputStream in = new ObjectInputStream(new FileInputStream("student.ser"));

the "readObject()" and "writeObject()" methods of the "ObjectInputStream" and "ObjectOutputStream"  classes
These methods are used to read an object and write an object

Example.
   
 Student s1= new Student();
    s1.sno=10; s1.sname="Ravi";
   
     out.writeObject(s1);
     Student s = (Student) in.readObject();


assuming that "out" and "in" are objects of "ObjectOutputStream" and "ObjectInputStream" classes

import java.io.*;
    class Student implements Serializable
    {
        int studentNo;
        String studentName;
        Student(){}
        Student(int studentNo,String studentName)
        {
            this.studentNo = studentNo;
            this.studentName = studentName;
        }
        void printStudent()
        {
            System.out.println(studentNo+":"+studentName); }   
    }

    class SerializeDemo
    {
        public static void main(String args[]) throws Exception
        {
            ObjectOutputStream out = new ObjectOutputStream(new FileOutputStream("student.ser"));

            Student s1 = new Student(10,"Ravi");
            out.writeObject(s1);
            System.out.println("object Serialzed..");
            System.out.println("read that object from another program...");
        }
    }


import java.io.*;
    class ReadSerializedObject
    {
        public static void main(String args[]) throws Exception
        {
            ObjectInputStream in = new ObjectInputStream(newFileInputStream("student.ser"));

            Student s1 = (Student) in.readObject();
            s1.printStudent(); 
        }
    }
   

The "transient" keyword
if we declare a variable using this keyword, then that variable will not serialized

ex
    class Student
    {
      int sno;
      transient int marks;
// not serialized     }

static variables are NOT SERIALIZED if a class implements "Serializable" interface then all its subclasses automatically become serializable

ex
    class A implements Serializable
   {   }

   class B extends A {   }
   class C extends B {   }

 class B and C automatically become serializable

the "NotSerializableException" class
if a class contains an object of other class that is NOT IMPLEMENTING the "Serializable" interface and if we try to serialize the source object that we get an exception called "NotSerializableException" at runtime

ex.
    class A {  }
   class B implements Serializable
   {
     A a1 = new A();  // exception      A a2; // no exception only reference     transient A a3=new A(); // no exception
                          //because transient
  }



The "java.io.Externalizable" interface

This interface extends the "Serializable" interface and declares two methods "readExternal()" and "writeExternal()"
This interface and its methods are used to control serialization. i.e we can write custom code in "readExternal()" and "writeExternal()" methods which are automatically executed when "readObject()" and "writeObject()" are executed.

class A implements Externalizable
    {
        public void readExternal() throws IOException,ClassNotFoundException
        { 
            some code
        }

        public void writeExternal() throws IOException,ClassNotFoundException
        {
            some code
        }
    }
    A a1 = new A();
    out.writeObject(a1);
    A temp = (A) in.readObject();



the "java.io.PrintWriter" class
This is a subclass of "Writer"
This is a convenient class for writing output

ex.
     PrintWriter pw = new PrintWriter(System.out,true);
     pw.println("hello");