Sunday, 6 July 2014

StarCount Program

public class Star
    {
            public static void main(String[] args)
            {
                    for(int i=0;i<4;i++)
               {
                        for(int j=0;j<=i;j++)
                       {
                               System.out.print("*");
                       }
                       System.out.println();
               }
      }
    }


output :

*
**
***
****

Tuesday, 24 June 2014

Why java is not supporting multiple inheritance

- - First reason is ambiguity around Diamond problem occurs.

- - multiple inheritances does complicate the design and creates problem during casting, constructor chaining etc 

- - Since interface only have method declaration and doesn't provide any implementation there will only be just one implementation of specific method hence there would not be any ambiguity.



Example :
   
  1. class A{  
  2. void msg(){System.out.println("Hello");}  
  3. }  
  4.   
  5. class B{  
  6. void msg(){System.out.println("Welcome");}  
  7. }  
  8.   
  9. class C extends A,B{//suppose if it were  
  10.    
  11.  Public Static void main(String args[]){  
  12.    C obj=new C();  
  13.    obj.msg();//Now which msg() method would be invoked?  
  14. }  
  15. }  

How to convert String to Number in java program

To convert a string into an int, use:
String str = "1234";
int num = Integer.parseInt(str);
To convert a number into a string, use:
int num = 1234;   
String str = String.valueOf(num);

Why there are no global variables in Java?

- -   The global variables breaks the referential transparency

- -   Global variables creates collisions in namespace.
- -  Global variables are usually a design flaw.
- - Your components should be self-contained and should not need any global state.
Instead, use private static fields.
- - Global variables (in the Java context - public static variables) are bad, because:
  • harder to maintain - you can't put a breakpoint or log each change to a variable, hence unexpected values at runtime will be very hard to track and fix
  • harder to test - read Miško Havery's post
  • harder to read - when someone sees the code he'll wonder:
    • where does this come from?
    • where else it is read?
    • where else it is modified?
    • how can I know what's its current value?
    • where is it documented?
To make one clarification that seems needed - variables != constants. Variables change, and that's the problem. So having a public static final int DAYS_IN_WEEK = 7 is perfectly fine - no one can change it.

Wednesday, 28 May 2014

concept of factory method and Singleton process

Singleton :

                A singleton class is one which allows  us to create only one object for JVM.
                we can use it to create a connection pool.

class Stest {
    private static Stest st;  // private variable

    private Stest() {       // private constructor
        System.out.println("OBJECT CREATED FIRST TIME");
    }

    public static Stest create()  //Factory method
    {
        if (st == null)
        {
            st = new Stest();
        } else
                {
                System.out.println("OBJECT ALREADY CREATED");
            }
       
        return st;
    }

    public static void main(String[] args) {
        Stest st1 = Stest.create();
        Stest st2 = Stest.create();
        Stest st3 = Stest.create();
        if ((st1 == st2) && (st2 == st3) && (st3 == st1)) {
            System.out.println("ALL OBJECTS ARE SAME");
        } else {
            System.out.println("ALL OBJECTS ARE NOT SAME");
        }
    }
}

OUTPUT :

OBJECT CREATED FIRST TIME
OBJECT ALREADY CREATED
OBJECT ALREADY CREATED
ALL OBJECTS ARE SAME

Tuesday, 27 May 2014

Algorithm to find if linked list contains loops or cycles

1) Use two pointers fast and slow
2) Move fast two nodes and slow one node in each iteration
3) If fast and slow meet then linked list contains cycle
4) if fast points to null or fast.next points to null then linked list is not cyclic



boolean hasLoop(Node first) {

    if(first == null) // list does not exist..so no loop either.
        return false;

    Node slow, fast; // create two references.

    slow = fast = first; // make both refer to the start of the list.

    while(true) {

        slow = slow.next;          // 1 hop.

        if(fast.next != null)
            fast = fast.next.next; // 2 hops.
        else
            return false;          // next node null => no loop.

        if(slow == null || fast == null) // if either hits null..no loop.
            return false;

        if(slow == fast) // if the two ever meet...we must have a loop.
            return true;
    }
}

Monday, 26 May 2014

When to use abstract class

public abstract Animal
{
   public void eat(Food food)
   {
        // do something with food.... 
   }

   public void sleep(int hours)
   {
        try
 {
  // 1000 milliseconds * 60 seconds * 60 minutes * hours
  Thread.sleep ( 1000 * 60 * 60 * hours);
 }
 catch (InterruptedException ie) { /* ignore */ } 
   }

   public abstract void makeNoise();
}
Note that the abstract keyword is used to denote both an abstract method, and an abstract class. Now, any animal that wants to be instantiated (like a dog or cow) must implement the makeNoise method - otherwise it is impossible to create an instance of that class. Let's look at a Dog and Cow subclass that extends the Animal class.
public Dog extends Animal
{
   public void makeNoise() { System.out.println ("Bark! Bark!"); }
}

public Cow extends Animal
{
   public void makeNoise() { System.out.println ("Moo! Moo!"); }
}
Now you may be wondering why not declare an abstract class as an interface, and have the Dog and Cow implement the interface. Sure you could - but you'd also need to implement the eat and sleep methods. By using abstract classes, you can inherit the implementation of other (non-abstract) methods. You can't do that with interfaces - an interface cannot provide any method implementations.

Saturday, 24 May 2014

How to make unhidden folder using java


Note : Keep folder jill .

public class hidedir

    public static void main(String[] args) throws Exception
    {
        String cmd="attrib -h C:/Users/Flutebala/Desktop/jill";
        Runtime.getRuntime().exec(cmd);

           }
}

How to show files list inside the folder

 NOTE : Keep folder jill and inside jill keep files .

public class ListFiles
{

 public static void main(String[] args)
{

  // Directory path here
  String path = "C:/Users/Flutebala/Desktop/jill";

  String files;
  File folder = new File(path);
  File[] listOfFiles = folder.listFiles();

  for (int i = 0; i < listOfFiles.length; i++)
  {

   if (listOfFiles[i].isFile())
   {
   files = listOfFiles[i].getName();
   System.out.println(files);
      }
  }
}
}

                                                           OR

public class ListFiles {

    public static void main(String[] args) {

        // Directory path here
        String path = "C:/Users/Flutebala/Desktop/jill";

        File f = new File(path);
        File[] listOfFiles = f.listFiles();
      
        for(File f1 : listOfFiles)
        {
            System.out.println(f1.getAbsolutePath());
        }
    }
}

How to make hidden folder using java

Note : Keep folder jill .

public class hidedir

    public static void main(String[] args) throws Exception
    {
        String cmd="attrib +h C:/Users/Flutebala/Desktop/jill";
        Runtime.getRuntime().exec(cmd);

           }
}

Sunday, 18 May 2014

Duplicate words in string

public class DuplicateWordSearcher {
@SuppressWarnings("unchecked")
public static void main(String[] args) {

String text = "java android java java android";

List<String> list = Arrays.asList(text.split(" "));

Set<String> uniqueWords = new HashSet<String>(list);
for (String word : uniqueWords)
{
System.out.println(word + ": " + Collections.frequency(list, word));
}
}
}


Output :
   android: 2
   java: 3

Monday, 31 March 2014

Swapping numbers

                                         Normal swapping

public class Swap {
   
 public static void main(String[] args) {
  int a =90;
  int b =50;
  a = a+b;
  b = a-b;
  a =a-b;
  System.out.println("A value is "+a);
  System.out.println("B value is "+b);
}
}


                                                       Swapping through method


public class Swap
{
    public static void m1(int a,int b)
    {
        int x= a;
        a=b;
        System.out.println("The nassigned value of a is--->"+a);
        System.out.println("The nassigned value of b is--->"+b);
        a=x;
        System.out.println("Swaped value of a to b is-->"+a);
        System.out.println("Swaped value of b to a is-->"+b);
     }

 public static void main(String[] args) {
 
  m1(10, 20);
}
}

Tuesday, 25 March 2014

ConcurrentModificationException

http://way2java.com/exceptions/concurrentmodificationexception/

As the name indicates, this exception is thrown when two objects are modifying a DS (like Vector or ArrayList) concurrently (at the same time when an operation, like iteration, is going on).

public class IteratorDemo {
    public static void main(String args[]) {
        ArrayList al1 = new ArrayList();
        al1.add("Raju");
        al1.add("Reddy");
        al1.add("Rao");
        al1.add("Ratnakar");
        ListIterator it1 = al1.listIterator();
        while (it1.hasNext()) {
            System.out.print(it1.next()+" ");
            it1.add("Setty");
            //al1.add("Goud");
        }
    }
}
As the name indicates, this exception is thrown when two objects are modifying a DS (like Vector or ArrayList) concurrently (at the same time when an operation, like iteration, is going on). - See more at: http://way2java.com/exceptions/concurrentmodificationexception/#sthash.DD6Jznku.dpuf
As the name indicates, this exception is thrown when two objects are modifying a DS (like Vector or ArrayList) concurrently (at the same time when an operation, like iteration, is going on). - See more at: http://way2java.com/exceptions/concurrentmodificationexception/#sthash.DD6Jznku.dpuf
As the name indicates, this exception is thrown when two objects are modifying a DS (like Vector or ArrayList) concurrently (at the same time when an operation, like iteration, is going on). - See more at: http://way2java.com/exceptions/concurrentmodificationexception/#sthash.DD6Jznku.dpuf
As the name indicates, this exception is thrown when two objects are modifying a DS (like Vector or ArrayList) concurrently (at the same time when an operation, like iteration, is going on). - See more at: http://way2java.com/exceptions/concurrentmodificationexception/#sthash.DD6Jznku.dpuf
As the name indicates, this exception is thrown when two objects are modifying a DS (like Vector or ArrayList) concurrently (at the same time when an operation, like iteration, is going on). - See more at: http://way2java.com/exceptions/concurrentmodificationexception/#sthash.DD6Jznku.dpuf

Wednesday, 5 March 2014

SNMP Protocol

http://www.manageengine.com/network-monitoring/what-is-snmp.html

What is SNMP ?

           --  Simple Network Management Protocol (SNMP) is an application–layer protocol defined by the Internet Architecture Board (IAB) in RFC1157 for exchanging management information between network devices.
          -- SNMP is one of the widely accepted protocols to manage and monitor network elements.
          -- It is used for collecting information from, and configuring, network devices, such as servers, printers, hubs, switches, and routers on an Internet Protocol (IP) network.
         -- You can monitor network devices such as servers, workstations, printers, routers, bridges, and hubs, as well as services such as Dynamic Host Configuration Protocol (DHCP) or Windows Internet Name Service (WINS).
         -- Use SNMP management software to monitor any network device on which you install SNMP agent software
         -- Using SNMP, you can monitor network performance, audit network usage, detect network faults or inappropriate access, and in some cases configure remote devices.
         --  SNMP commands to read and write data in each device MIB. 'Get' commands typically retrieve data values, while 'Set' commands typically initiate some action on the device.
         -- For example, a system reboot script is often implemented in management software by defining a particular MIB attribute and issuing an SNMP Set from the manager software that writes a "reboot" value into that attribute.

      
SNMP consists of


SNMP Manager --
                -- 

toString() method

-- If you want to represent any object as a string, toString() method comes into existence.

If you print any object, java compiler internally invokes the toString() method on the object. So overriding the toString() method, returns the desired output, it can be the state of an object etc. depends on your implementation.

Advantage of the toString() method

By overriding the toString() method of the Object class, we can return values of the object, so we don't need to write much code.

Understanding problem without toString() method

Let's see the simple code that prints reference.
  1. class Student{  
  2.  int rollno;  
  3.  String name;  
  4.  String city;  
  5.   
  6.  Student(int rollno, String name, String city){  
  7.  this.rollno=rollno;  
  8.  this.name=name;  
  9.  this.city=city;  
  10.  }  
  11.   
  12.  public static void main(String args[]){  
  13.    Student s1=new Student(101,"Raj","lucknow");  
  14.    Student s2=new Student(102,"Vijay","ghaziabad");  
  15.      
  16.    System.out.println(s1);//compiler writes here s1.toString()  
  17.    System.out.println(s2);//compiler writes here s2.toString()  
  18.  }  
  19. }  
Output:Student@1fee6fc
       Student@1eed786
As you can see in the above example, printing s1 and s2 prints the hashcode values of the objects but I want to print the values of these objects. Since java compiler internally calls toString() method, overriding this method will return the specified values. Let's understand it with the example given below:

Example of toString() method

Now let's see the real example of toString() method.
  1. class Student{  
  2.  int rollno;  
  3.  String name;  
  4.  String city;  
  5.   
  6.  Student(int rollno, String name, String city){  
  7.  this.rollno=rollno;  
  8.  this.name=name;  
  9.  this.city=city;  
  10.  }  
  11.    
  12.  public String toString(){//overriding the toString() method  
  13.   return rollno+" "+name+" "+city;  
  14.  }  
  15.  public static void main(String args[]){  
  16.    Student s1=new Student(101,"Raj","lucknow");  
  17.    Student s2=new Student(102,"Vijay","ghaziabad");  
  18.      
  19.    System.out.println(s1);//compiler writes here s1.toString()  
  20.    System.out.println(s2);//compiler writes here s2.toString()  
  21.  }  
  22. }  
Output:101 Raj lucknow
       102 Vijay ghaziabad

Equals() method

Note -- ‘equals()’ method check for the content equality
              Operator will check object.. whether object is same or not


public class EqualsMethod {
    public static void main(String[] args) {
        String s1 = new String("bala");
        String s2 = new String("bala");
        if (s1.equals(s2)) // using equals method
        {
            System.out.println("Content are same -- TRUE");
        } else {
            System.out.println("Content are different -- FALSE");
        }
        if (s1 == s2) // using operator
        {
            System.out.println("Object is same -- TRUE");
        } else {
           System.out.println("Object is different -- FALSE");
        }
    }
}

Wednesday, 26 February 2014

System.out.println


System is a class in the java.lang package.
out is a static member of the System class, and is an instance of java.io.PrintStream.
println is a method of java.io.PrintStream. This method is overloaded to print message to output destination, which is typically a console or file.


1)System: It is the name of standard class that contains objects that encapsulates the standard I/O devices of your system.
It is contained in the package java.lang.Since java.lag package is imported in every java program by default,therefore java.lang packageis the only package in Java API which doesnot require an import declaration.
2)out:The object out represents output stream(i.e Command window)and is the static data member of the class system.
So note here System.out (System -Class & out- static object i.e why its simply refered by classname and we need not to create any object).
3).println:The println() is method of out object that takes the text string as an argument and displays it to the standard output i.e on monitor screen.

 
Note:
 System -Class
out -static Object
println() -method

Friday, 21 February 2014

Sorted Array





public class ArraySort {

public static void main(String[] args) {
int a[] = {6,500,700,200,1000,1};   
int temp=0;
/*** Ascending Order ***/
for(int i=0;i<a.length;i++)
{   
for(int j=a.length-1;j>i;j--)
{   
if(a[i]>a[j]){
temp = a[i];
a[i] = a[j];
a[j] = temp;   
}
}
}
for(int i=0;i<a.length;i++)
System.out.println("a["+i+"] = "+a[i]);
}
}



                                                   (OR)

public class Test {
    public static void main(String[] args)
    {
        int a[] = {6,500,700,200,1000,1};   
        int temp=0;
        /*** Descending Order***/
        for(int i=0;i<a.length;i++)
        {   
        for(int j=0;j<a.length;j++)
        {   
        if(a[i]>a[j]){
        temp = a[i];
        a[i] = a[j];
        a[j] = temp;   
        }
        }
        }
        for(int i=0;i<a.length;i++)
            System.out.println("a["+i+"] = "+a[i]);
    }
                                                       (OR)
public class SortedArray
{
    public static void main(String[] args) {

        int a[]={30,7,9,20};
        Arrays.sort(a);
        System.out.println(Arrays.toString(a));
}
}

Tuesday, 18 February 2014

String character counting using for loop

public class CountCharacters {

    public static void main(String args[])
    {
        
        String input = "Today is tuesday"; //count number of "a" on this String.
        int charCount = 0;
        for(int i =0 ; i<input.length(); i++){
            if(input.charAt(i) == 'd'){
                charCount++;
            }
        }
        System.out.println("count of character 'd' on String: 'Today is Monday' using for loop  " + charCount);
}
}

Monday, 3 February 2014

Parsing

Parsing : -
              -- Parsing is to read the value of one object to convert it to another type.
              -- For example you may have a string with a value of "10". Internally that string contains the Unicode characters '1' and '0' not the actual number 10.
              -- The method Integer.parseInt takes that string value and returns a real number.

Example :

        public class Parsing {
        public static void main(String[] args) {
        String somestring ="10";
        int i = Integer.parseInt(somestring);
        System.out.println(i);
}
}
               

Polymorphism

-- Concept of exhibiting different behaviours in different situations by a method is known as polymorphism.

There are 2 types of polymorphism.
1.Method or static polymorphism
2.Object or dynamic polymorphism

Static polymorphism :

              --  Here the same method will give different result based on the arguments that we are passing so this is known as method polymorphism.
              -- which method has to be executed will be decided by the compiler during the compilation is known as static polymorphism.
              --  We can achieve the method polymorphism using method overloading.
             -- compiler it self will decide which method has to be executed first is known as“StaticPolymarphism”

 Method overloading or method overwriting:-
                                       --Concept of defining a method with same name and with different signatures is known as method overloading.


Dynamic Polymorphism :

              -- Same method will give different result based on the object acting upon it.(object polymorphism)
              -- In this case which method has to be executed will be decided by the jvm during runtime(dynamic)
              -- We can achieve dynamic polymorphism by using method overriddenig.

Method overriding :
              -- Concept of defining the same method with same signature inside the subclass.

Sunday, 2 February 2014

Encapsulation

 --  Binding the data along with their corresponding functionalities.
 -- we achieve the concept of encapsulation only by declaring all the variables as private and providing public setter,getter methods
 -- javaBeans are used to transfer the data. so, java beans are also known as "data transfer objects" (DTO).
this is used to set the value and get the values.so,it is known as "value object"(VO)

example :

public class Employee {
    private int id;
    private String name;
    private String addr;
    public int getId() {
        return id;
    }
    public void setId(int id) {
        this.id = id;
    }
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    public String getAddr() {
        return addr;
    }
    public void setAddr(String addr) {
        this.addr = addr;
    }
   

}

package com.pointred.encaptest;

public class Test {
    public static void main(String[] args) {
        Employee em = new Employee();
        em.setId(4);
        em.setName("bala");
        em.setAddr("bangalore");
        System.out.println("values are "+em.getName()+" " +em.getAddr() +" "+em.getId());
       
    }

}

Deserialization

--Process of reading the state of an object from the byte stream is known as Deserialization

serialization

1.Serialization ?

          -- process of writing the state of an object into a byte stream which is known as serialization.
          --   State of an object” means data present in the object at any instance of time.
          -- If any class is implementing serializable interface JVM will support to convert the state of object of those classes into a byte stream
          --  Transferring the data contained in the object from RAM to hard disk is known as Serialization.
         --Transfering data through network that Object most be a serializable object that means it helps in decoding data before tranfering and encode the data after revecing.


Example :

public class Student implements Serializable {
    int id;
    String name;
    public Student(int id,String name)
    {
        this.id = id;
        this.name = name;
    }
}

import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.ObjectOutputStream;

public class Persist {
public static void main(String[] args) throws Exception {
    Student s = new Student(3, "bala");
    try {
        FileOutputStream fout = new FileOutputStream("E:/f.txt");
        ObjectOutputStream out = new ObjectOutputStream(fout);
        out.writeObject(s);
        out.flush();
        System.out.println("Serialized data saved");
    } catch (Exception e) {
        // TODO: handle exception
        e.printStackTrace();
    }
   
}
}

Tuesday, 28 January 2014

String Reverse Program

 public class ReverseProgram{
    public static void main(String[] args) {
        String a="Siva";
        for(int i = a.length() - 1; i >= 0; --i)
    {
        System.out.print(a.charAt(i));
    }

}
}
                                  (or)

public class String_reverse
{
public static void main(String[] args)
{
Scanner sc=new Scanner(System.in);
System.out.println("Enter String :");
String n=sc.nextLine();
String rev="";
int len=n.length();
for(int i=len-1;i>=0;i--)
{
rev=rev+n.charAt(i);
}
System.out.println("Reverse of Given String is :");
System.out.println(""+rev);
}
}

Monday, 27 January 2014

Factorial Program

public class Factorial {
   
    int fact(int number)
    {
        int f=1;
        for(int i=1;i<=number;i++)
        {
            f = f*i;
        }
        return f;
    }
    public static void main(String[] args) {
        Factorial fa = new Factorial();
        int ab=fa.fact(4);
        System.out.println(ab);
       
    }
}

Fibonacci Series

public class Fibonacci
{
    public static void main(String[] args)
    {
        int f = 0;
        int g = 1;

        for(int i = 1; i <= 10; i++)
        {
            f = f + g;
            g = f - g;
            System.out.print(f + " ");
        }

        System.out.println();
    }
}

Saturday, 25 January 2014

Tavant interview questions

1. Sort integer array ?
  
               public class SortedArray
{
    public static void main(String[] args) {

        int a[]={30,7,9,20};
        Arrays.sort(a);
        System.out.println(Arrays.toString(a));
}
}

2. Sort integer array without using Array.sort by ascending

  public class ArraySort {
public static void main(String[] args) {
int a[] = {6,500,700,200,1000,1};   
int temp=0;
/*** Ascending Order ***/
for(int i=0;i<a.length;i++)
{   
for(int j=a.length-1;j>i;j--)
{   
if(a[i]>a[j]){
temp = a[i];
a[i] = a[j];
a[j] = temp;   
}
}
}
for(int i=0;i<a.length;i++)
System.out.println("a["+i+"] = "+a[i]);
}
}

                  
3. Sort integer array without using Array.sort by decending

            public class Test {
    public static void main(String[] args)
    {
        int a[] = {6,500,700,200,1000,1};   
        int temp=0;
        /*** Descending Order***/
        for(int i=0;i<a.length;i++)
        {   
        for(int j=0;j<a.length;j++)
        {   
        if(a[i]>a[j]){
        temp = a[i];
        a[i] = a[j];
        a[j] = temp;   
        }
        }
        }
        for(int i=0;i<a.length;i++)
            System.out.println("a["+i+"] = "+a[i]);
    }
    }

4. why need to use overriding ?

             Consider Manager is a super class and Employee is a child class.
             Both class has work() .
             But in Manager,he only manage and in Employee, he will do coding. But basically Manager and Employee are worker.
            Their work is different based on class.

5. What is Generic ?
             A class or interface that operates on parameterized type is called Generic.
             Generic also provide type safety.
             we cannot use other class object .

6.How to sort employee details using comparable ?

                 class Student implements Comparable<Student> {
    int rollno;
    String name;
    int age;
    public int getRollno() {
        return rollno;
    }
    public void setRollno(int rollno) {
        this.rollno = rollno;
    }
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    public int getAge() {
        return age;
    }
    public void setAge(int age) {
        this.age = age;
    }
        public int compareTo(Student obj)
    {
        return this.rollno - obj.rollno;
    }
}

public class Simple {
   
    public static void main(String[] args) {
        ArrayList al = new ArrayList();
        Student a = new Student();
        a.setAge(2);
        a.setName("bala");
        a.setRollno(5);
        Student b = new Student();
        b.setAge(1);
        b.setName("sures");
        b.setRollno(67);
        Student c = new Student();
        c.setAge(8);
        c.setName("ramesh");
        c.setRollno(43);
        al.add(a);
        al.add(b);
        al.add(c);
        Collections.sort(al);
        Iterator itr = al.iterator();
        while(itr.hasNext())
        {
            Student st=(Student)itr.next();
            System.out.println(st.age+" "+st.name+" "+st.rollno);
        }
       
    }

}

7. Reverse the string ?

            public class StringReverseExample{
       public static void main(String[] args){
          String string="How to name it";
          String reverse = new StringBuffer(string).
          reverse().toString();
          System.out.println("\nString before reverse:" +string);
          System.out.println("String after reverse:"+reverse);
       }
    }
                     

8.Difference between executeUpdate and executeQuery ?

  1. int executeUpdate(String SQL) : Returns the numbers of rows affected by the execution of the SQL statement. Use this method to execute SQL statements for which you expect to get a number of rows affected - for example, an INSERT, UPDATE, or DELETE statement.
  2. ResultSet executeQuery(String SQL) : Returns a ResultSet object. Use this method when you expect to get a result set, as you would with a SELECT statement.

Saturday, 4 January 2014

1. What is log4j
    This is a Open Source tool given by Apache, for only java projects, to record or write the status of an application at various places
  • Working with log4j is nothing but working with classes & interfaces given in org.apache.log4j.*
  • Log4j is a common tool, used for small to large scale Java/J2EE projects
  • In Log4j we use log statements rather SOPL statements in the code to know the status of a project while it is executing
  • In real time, after a project is released and it is installed in a client location then we call the location as on-site right, when executing the program at on-site location, if we got any problems occurred then these problems must report to the off showered engineers,  in this time we used to mail these Log files only so that they can check the problems easily

2. What is web application
       A Web application (Web app) is an application program that is stored on a remote server and delivered over the Internet through a browser interface.

3.postgresql vs MySQL
          --  PostgreSQL is more reliable because it is ACID (Atomicity, Consistency, Isolation, and Durability) compliant which means queries will maintain data integrity, and return the same output without error.
         -- MySQL is less reliable and not ACID compliant: The way it handles foreign key references, auditing and transactions make it less reliable. MySQL is good if you are thinking you may use code from other open source projects. Since it is widely used in smaller websites,

       

4. what is SNMP

5.what is SNMP Manager

6.what is snmp agent

7.explain SNMP simulator

8.SNMP Ports are

9. IP in which OSI layer

10.What is Managed Device

11.what is network manager

12.what is MIB

13.what is OID

14.MIB order names



15.What is Socket
                    

Definition: A socket is one end-point of a two-way communication link between two programs running on the network.                - -  When a computer program needs to connect to a local or wide area network such as the Internet, it uses a software component called a socket. The socket opens the network connection for the program, allowing data to be read and written over the network. It is important to note that these sockets are software, not hardware, like a wall socket. So, yes, you have a much greater chance of being shocked by a wall socket than by a networking socket.

16.What is SSL
                 
              - -SSL (Secure Sockets Layer) is a standard security technology for establishing an encrypted link between a server and a client—typically a web server (website) and a browser; or a mail server and a mail client (e.g., Outlook).

SSL allows sensitive information such as credit card numbers, social security numbers, and login credentials to be transmitted securely. Normally, data sent between browsers and web servers is sent in plain text—leaving you vulnerable to eavesdropping. If an attacker is able to intercept all data being sent between a browser and a web server they can see and use that information.
More specifically, SSL is a security protocol. Protocols describe how algorithms should be used; in this case, the SSL protocol determines variables of the encryption for both the link and the data being transmitted.

Short for Secure Sockets Layer, a protocol developed by Netscape for transmitting private documents via the Internet. SSL uses a cryptographic system that uses two keys to encrypt data − a public key known to everyone and a private or secret key known only to the recipient of the message.

https://www.globalsign.eu/ssl-information-center/what-is-ssl.html


17. Object-relational mapping (ORM, O/RM, and O/R mapping)
                              In computer software is a programming technique for converting data between incompatible type systems in object-oriented programming languages.

18.What is hashcode in java?
                             1) when an object is created by JVM, it returns the memory address of the object as a hexadecimal number, which is called object reference or hashcode. When a new object is created, a new reference number is allocated to it.It means every object will have a unique reference.

  --If we want to see the object's hashcode, by using hashCode() method we can see hashcode of object. hashCode() method presents in Object class which is super class for every predefined class and user defined class.

  --For every object JVM will assign a unique value which is nothing but hash code



EX:

class One
{
public static void main(String args[])
{
One o=new One();
System.out.println(o.hashCode());
}
}

Output: 4072869

19. What is Hashing?
            -- Hashing is the transformation of a string of characters into a usually shorter fixed-length value or key that represents the original string.