Monday, November 30, 2015

Interview Procedure in Multinational Company's for freshers

In this post i am sharing Recently i attended the HP interview which was a pooled off campus drive conducted in Bangalore. It was two days interview process.This page is very helpful who are pursuing Final year students. Most of the students having lack of knowledge how the interviews will conduct in off - campus. So here is maximum multinational company's will conduct interview process.

Rounds:

  • Online Test
  • Technical
  • Manager round
  • HR round

Day 1:


Online Test: Sections

1) Qantas
2) DBMS
3) Operating System
4) Programming
5) Computer Networking

1) Qantas:

I remember some questions like
  • Venn diagrams
  • calendar
  • Blood relations
2) DBMS:

I remember some questions like

  • Queries
  • File Systems
  • Data Models
3) Operating System

I remember some questions like
  • Paging
  • Threads
  • Thrashing
  • kernel
  • Multiprocessor
4) Programming

  • Find the error
  • Find the output(Basic knowledge in programming is enough to answer)
5) Computer Networking:
  • LAN
  • WAN
  • ISDN FULL FORM
  • ROUTER

DAY 2:

  1. Technical
  2. Manager Round
  3. HR ROUND

1) Technical:

  • Armstrong No
  • SQL Queries
  • Swapping of two no's without using third variable
  • what is macro
  • Reverse no
  • asked explain about my project
Recommended to Read:

2) Manager Round

  • What will you do if your colleagues don not work and you can start your work only after they complete?
  • What will you do when you are not able to finish your work on time?
  • What will you do you have so many problems because of your team members?
  • what do you know about HP?
  • What do you expect from HP?
NOTE:

who cleared Manager Round they were selected.
Next HR round was just a formality round where no one
was rejected.

3) HR Round:

  • Preferred Location
  • certifications course(if any)
  • Language where i need training
  • situation that highlights my leadership quality

Recommended to Read:   

You must have learn some basic Programs either C or JAVA

  • Fibonacci
  • factorial
  • reversing no
  • palindrome for string and no
  • Armstrong no
  • leap year or not
  • floyd's triangle
Go through the company website and Collect info about
  • locations
  • founder
  • their key areas
  • CMM Level
  • employees number
  • the CEO
Finally i suggest you people speak confidently and have a smiley on your face















Sunday, November 29, 2015

how to burn a cd in windows 7 using nero

Write to a CD-R (This process uses the Nero Burning software)

First insert a blank disc on your CD/DVD drive.
 An AutoPlay window will open so choose burn
 files to disc:
















Another prompt will appear and this time asking you to choose between the two options of burning.  The default is the “mastered” option which lets you burn files traditionally – the burned files are read only files so you will not be able to edit or remove them after burning.

The other option is the “live file system” where you can save files like on a USB flash drive – it means you can save, edit and delete files on the disc anytime.  The disadvantage is that it is not compatible with players outside XP, Vista and Windows 7.   so if you want to burn a disc that you want your XBOX 360 to recognize, burn it using the default mastered option.


















In this window, enter the title of the disc then click next.  You should see your drive on Explorer with a label that says “drag files to folder…”

















Using Windows 7’s side by side snap view position the window above to the left side and another window to the right side.  This way you can see the files being added up as you drag files from the right Explorer window to the left.














Click the “burn to disc button”









You may edit the title of the disc or adjust the recording speed.  By default it will choose the recording speed supported by your disc.  Click the next button to begin the burning process.
















That' it............

ArrayList in java with Examples

ArrayList in Java:

ArrayList is dynamic Data Structure.That means elements can be add or removed from list.But Normal array in java is a  static data structure because once you fixed size of array we can not increase the size of array.

An array is an indexed collection of fixed number of homogeneous data elements.

The main limitations of Object Arrays are

1) Arrays are fixed in size i.e once we created an array there is no chance of increasing or
decreasing it’s size based on our requirement.

2) Arrays can hold only homogeneous data elements.

The underlying data Structure for ArrayList() is resizable Array or “Growable Array”.

  • Duplicate objects are allowed.
  • Insertion order is preserved.
  • Heterogeneous objects are allowed.
  • ‘null’ insertion is possible.
To set up an ArrayList you need to import the package from java.util.*;

Import java.util.ArrayList;



Constructors of Array List


ArrayList l = new ArrayList();

Creates an empty ArrayList object with default intitial capacity 10.
When ever ArrayList reaches its max capacity a new ArrayList Object will be created with new capacity.
capacity=(current capacity*3/2)+1

ArrayList l = new ArrayList(int initial capacity)

Creates an empty ArrayList Object with the specified initial capacity.
ArrayList l = new ArrayList(Collection c)

For inter conversion between collection objects.

Ex:
import java.util.*;
class ArrayListDemo
{
public static void main(String arg[])
{
ArrayList a = new ArrayList();
a.add("A");
a.add(new Integer(10));
a.add("A");
a.add(null);
System.out.println(a);
a.remove(2);
System.out.println(a);
a.add(2,"M");
a.add("N");
System.out.println(a);
}
}
OutPut:
A 10 A null
A 10 null
A 10 M null N

ArrayList and vector classes implement RandomAccess interface. So that we can access any element with the same speed. Hence ArrayList is best suitable if our frequent operation is retrieval operation.Usually the collection objects can be used for data transport purpose and hence every collection implemented class already implemented serializable and cloneable interfaces.ArrayList is the worst choice if u want to perform insertion or deletion in the middle.

Note:- 
ArrayList is not recommended if the frequent operation is insertion or deletion in the middle.To handle this requirement we should go for linked list.

Example of ArrayList Class:

import java.util.*;
class ArrayListEx{
public static void main(String args[])
{
ArrayList<String>al=new ArrayList<String>();//creating arraylist
al.add("lucky");//adding object in arraylist
al.add("sir");
al.add("shiva");
Iterator itr=al.Iterator();//getting iterator from arraylist to traverse elements
while(itr.hasNext())
{
System.out.println(itr.next());
}
}
}
Output:
lucky
sir
shiva




Saturday, November 28, 2015

Generics in Java with examples

Generics in java:

Generics were Introduced in as one of the features in JDK 5. I will be covering everything i find useful with java generics and related to them.Java Generics are a language feature that allows for definition and use of generic types and methods.

Why Generics in Java:
Array Objects are by default type-safe. i.e. we can declare String array and we can insert only String Objects.By mistaking we are trying to insert any other elements we will get compile time error.
Ex:
String [] s=new String[100];
s[0]="lucky";
s[1]=10;//raised compile time error

But collection objects are not typesafe by default. If our requirement is to add only String Objects to the ArrayList, By Mistake if we are trying to insert any other element we won't get any compile time error.
Ex:
ArrayList al=new ArrayList();
al.add("lucky");
al.add(new Integer(10));//no compile time error

While retrieving array elements there is no need to perform typecasting
Ex:
String name=s[0];//typecasting not required here

But while retrieving array elements from ArrayList we should  perform typecasting.

Ex:
String name=al.get[0];//compile time error
String name=(String)al.get[0]// no compile time error

So you people understand what problems we facing here, so to resolve above two problems(typesafety,typecasting) sun people introduced Generics concept in the JAVA 1.5 version.

If we want create ArrayList object to hold any String objects we have to define as fallows.

ArrayList<String> al=new ArrayList<String>();

For this ArrayList  we can add only String Objects,by mistake if we are trying to add any other type elements we will get compile time error.

EX:
al.add("lucky");
al.add(new Integer(10));//compile time error

It show compile time error like "can't find the symbol add(Integer)
At that time of retrieval  no need to perform any typecasting.

Ex:
String name=al.get[0];//no typecasting required here

NOTE:

Hence by using generics we can provide typesafety and we can resolve typecasting problems..

Parameter Generics in java:

By using  generics we can define parameter for the collection. These parameterized collection classes are nothing but "Generic Collecton classes"

Note:

Polymorphism concept not applicable for parameter type but applicable for base type.

EX 1:

  


Ex 2:









The type  parameter must be Object type(any class or interface name).
We can't apply generic  concept for Primitive datatype.


Ex:- 

ArrayList<int> l = new ArrayList<int>();



C.E:- unexpected type found : int
Required : Integer


Generic Class

Until java 1.4 version we have ArrayList class with the  declaration as fallows.

Class ArrayList{
add(Object 0);
Object.get(int index);
}
Her add method contain Object as an argument,hence we can add any type of object.
But we can not get any type safety. The return type of get() method is object hence at the time of retrieval we should perform typecasting.

But in the Java 1.5 version we have generics ArrayList class with definition as follows;

Ex:

Class ArrayList<T >{
add(T t);
T get(int);

Based on runtime requirement the corresponding version of ArrayList will loaded.

ArrayList<String>al=new ArrayList<String>();

For the fallowing declaration the corresponding loaded class is:

Class ArrayList<String>{
add(String);
String get(int);
}
Note:

The argument to the add method is String hence we should add only String Object as the result we will get type safety.
The return type of get() method is String. Hence at the time of retrieval no need to perform typecasting.

We can get our own Generic class also

Ex:

class gen<T>
{
T ob;
gen(T ob)
{
this.ob = ob;
}
public void show()
{
System.out.println("The type of Object is : "+ob.getClass().getName());
}
public T getOb()
{
return ob;
}
}
class GenericsDemo
{
public static void main(String[] args)
{
gen<String> g1 = new gen<String>("lucky");
g1.show();
System.out.println(g1.getOb());
gen<Integer> g2 = new gen<Integer>(10);
g2.show();
System.out.println(g2.getOb());
}
}
Output:
The type of Object is : java.lang.String
lucky

Bounded Types:
we can bound the type of parameter for a particular range.Such type of  types is called"Bounded Types".

we can achieve this by using extends Keyword.

Ex:
class Gen<T>
{
}

Here we can pass any types as the type parameter and there are no restrictions.

Gen<String> g1 = new Gen<String>();//applicable
Gen<Integer> g2 = new Gen<Integer>();//applicable


In generics we have only extends keyword and there is no implements keyword. It’s purpose is also survived by using extends keyword only.

Ex:

class Gen<T extends Number>
{
T ob;
Gen(T ob)
{
this.ob = ob;
}
void show()
{
System.out.println("The int value is :" + ob.intValue());
}
}
class GenDemo
{
public static void main(String arg[])
{
Gen<Integer> t1 = new Gen<Integer>(new Integer(10));
t1.show();
Gen<Double> t2 = new Gen<Double>(10.5);
t2.show();
Gen<String> t3 = new Gen<String>("raju");
t3.show();
}
}

Generic Methods:

1) m1(ArrayList<String>)
   
   It is applicable for ArrayList of only String type.

2) m1(ArrayList<? extends x> l)

Here if ‘x’ is a class then this method is applicable for ArrayList of either x or it’s child             classes.
If ‘x’ is an interface then this method is applicable for ArrayList of any implementation           class of x

3) m1(ArrayList <? Super x> l)

If ‘x’ is a class then this method is applicable for ArrayList of either x or it’s super classes.

If ‘x’ is an interface then this method is applicable for ArrayList of any super classes of implemented
class of x.

4) m1(ArrayList <?> l)

This method is applicable for ArrayList of any type.

In the method declaration if we can use ‘?’ in that method we are not allowed to insert any element except null. Because we don’t know exactly what type of object is coming.

EX:


class Test

{
public static void main(String arg[])
{
ArrayList<String> l1 = new ArrayList<String>();
l1.add("A");
l1.add("B");
l1.add("C");
l1.add("D");
m1(l1);
ArrayList<Integer> l2 = new ArrayList<Integer>();
l2.add(10);
l2.add(20);
l2.add(30);
l2.add(40);
m1(l2);
}
public static void m1(ArrayList<?> l)
{
//l.add("D");//compile time error  Because we can’t expect what type of value
will come
l.remove(1);
l.add(null);
System.out.println(l);
}
}

Output:

[A, C, D, null]
[10, 30, 40, null]













How To Install MySQL Server on Windows7

HOW TO INSTALL MYSQL SERVER ON WINDOWS 7

Introduction:

MYSQL is Open Source database
and it can be easily be installed on
windows 7

Download & Installation




Download

You can download the MySQL database from the MySQL website http://www.mysql.com by clicking on the downloads tab. Scroll down to the MySQL database server & standard clients section and select the latest production release of MySQL, 5.0.24 a at the time of writing.

Installation of MySQL Server

Unzip the setup file and execute the downloaded MSI file. Follow the instructions below exactly when Installing MySQL Server.



Configure MySql Server:


If you checked the Configure the MySQL Server now check box on the final dialog of the MySQL Server installation, then the MySQL Server Instance Configuration Wizard will automatically start.

Follow the instructions below carefully to configure your MySQL Server to run correctly with
EventSentry.



Note:
It is recommended that you use a Dedicated MySQL Server Machine for your
MySQL database, if this is not an option then select "Server Machine".



Note:
Select Transnational Database Only, this will make sure that InnoDB is the main storage engine.



Note:

Select the drive where the database files will be stored.
Select the drive on the fastest drive(s) on your server.



Note:

Enter the number of agents you are monitoring, multiplied by two.
For example, if you are monitoring 20 servers then enter 40.



Note:

It is recommended that you leave the default port 3306 in place, however
EventSentry will also work with non-standard ports if necessary.



Note:

It is highly recommended that you run the MySQL Server as a Windows
service and include the binary directory in the search path.



Specify a secure root password, you may want to check the box Enable root access
from remote machines if you plan on administering your MySQL server
from your workstation or other servers.


Note:

If you see this dialog then your instance was setup correctly

Thursday, November 26, 2015

Serialization in Java With Examples

serialization Introduction

Serialization: The Process of Saving an object to a file is called “serialization”. But strictly 
speaking serialization is the process of converting an object from java supported format to network or file supported.




By using FileOutPutStream, ObjectOutPutStream classes we can achieve serialization

Deserialization: The process of reading an object from a file is called deserialization. But strictly speaking it is the process of Converting an object from network supported format or file supported format to java supported format.

By using FileInputStream, ObjectInputStream we can achieve deserialization.


Ex:-

class Dog implements Serializable
{
int i= 10;
int j= 20;
}
class serializedemo
{
public static void main(String arg[])
{
Dog d = new Dog();
FileOutputStream fos = new FileOutputStream("abc.ser");
ObjectOutputStream oos = new ObjectOutputStream(fos);
oos.writeObject(d);
FileInputStream fis = new FileInputStream("abc.ser");
ObjectInputStream ois = new ObjectInputStream(fis);
Dog d1 = (Dog)ois.readObject();
System.out.println(d1.i+"---"+d2.j);
}
}

Customized Serialization
During default Serialization there may be a chance of loss of information because of transient variables.

Example:

import java.io.*;
class Dog implements Serializable
{
transient Cat c = new Cat();
}
class Cat
{
int j= 20;
}
class SerializeDemo
{
public static void main(String arg[])throws Exception
{
Dog d = new Dog();
System.out.println("Before Serialization:"+d.c.j);
FileOutputStream fos = new FileOutputStream("abc.ser");
ObjectOutputStream oos = new ObjectOutputStream(fos);
oos.writeObject(d);
FileInputStream fis = new FileInputStream("abc.ser");
ObjectInputStream ois = new ObjectInputStream(fis);
Dog d1 = (Dog)ois.readObject();
System.out.println(d1.c.j);
}
}


Internal Process of Diagrammatic Form



In the above program before serialization dog object tell ‘j’ value. But after deserialization dog object can’t tell j value(d1.c.j) will rise NullPointerException.
i.e during Serialization there may be a chance of loss of information. To recover this information we should customize Serialization process. which is nothing but “Customized Serialization”

We can implement customized Serialization by using the following two methods.

We can implement customized Serialization by using the following two methods.
private void writeObject(OutputStream os)throws Exception
{
….
….
….
}
This method will be executed automatically by the JVM at the time of Serialization.
private void readObject(InputStream is)throws Exception
{
….
….
….
}
This method will be executed automatically by the JVM at the time of deSerialization.

Ex:-
import java.io.*;
class Dog implements Serializable
{
transient Cat c = new Cat();
private void writeObject(ObjectOutputStream os)throws IOException
{
int x = c.j;
os.writeInt(x);
}
private void readObject(ObjectInputStream is)throws IOException,
ClassNotFoundException
{
is.defaultReadObject();
c=null
d
d
j=20
c
Cat
c=null
d
int k = is.readInt();
c = new Cat();
c.j = k;
}
}
class Cat
{
int j= 20;
}
class SerializeDemo
{
public static void main(String arg[])throws Exception
{
Dog d = new Dog();
System.out.println("Before Serialization:"+d.c.j);
FileOutputStream fos = new FileOutputStream("abc.ser");
ObjectOutputStream oos = new ObjectOutputStream(fos);
oos.writeObject(d);
FileInputStream fis = new FileInputStream("abc.ser");
ObjectInputStream ois = new ObjectInputStream(fis);
Dog d1 = (Dog)ois.readObject();
System.out.println(d1.c.j);
}
}
O/P:- 20

Inheritance in Serialization


If the parent class is Serializable bydefault all the child classes also Serializable. i.e Serializable nature is inherited from parent to child.

Ex:-

import java.io.*;
class Animal implements Serializable
{
int i = 10;
}
class Dog extends Animal
{
int j = 20;
}
class SerializeDemo
{
public static void main(String arg[])throws Exception
{
Dog d = new Dog();
FileOutputStream fos = new FileOutputStream("abc.ser");
ObjectOutputStream oos = new ObjectOutputStream(fos);
oos.writeObject(d);
FileInputStream fis = new FileInputStream("abc.ser");
ObjectInputStream ois = new ObjectInputStream(fis);
Dog d1 = (Dog)ois.readObject();
System.out.println(d1.i+"-----"+d1.j);
}
}

If the child class is Serializable and some of the parent classes are not Serializable, Still we are allowed to serialize child class Objects. While performing serialization JVM ignores the inherited variables which are coming from non-serializable parents.

While performing de-serialization JVM will check is there any parent class is non-serializable or not.

If any parent is non-serializable JVM will create an object for every non-serializable parent and share it’s instance variables for the current child object.

The non-serializable parent class should compulsory contain no-argument constructor other wise we will get
runtime error.

Ex:-

import java.io.*;
class Animal
{
int i = 10;
Animal()
{
System.out.println("Animal Constructor");
}
}
class Dog extends Animal implements Serializable
{
int j = 20;
Dog()
{
System.out.println("Dog Constructor");
}
}
class SerializeDemo
{
public static void main(String arg[])throws Exception
{
Dog d = new Dog();
d.i = 888;
d.j = 999;
System.out.println(d.i+"-----"+d.j);
System.out.println("Serilization Started");
FileOutputStream fos = new FileOutputStream("abc.ser");
ObjectOutputStream oos = new ObjectOutputStream(fos);
oos.writeObject(d);
System.out.println("Deserialization Started");
FileInputStream fis = new FileInputStream("abc.ser");
ObjectInputStream ois = new ObjectInputStream(fis);
Dog d1 = (Dog)ois.readObject();
System.out.println(d1.i+"-----"+d1.j);
}
}

Output:



High Paying Jobs after Learning Python

Everyone knows Python is one of the most demand Programming Language. It is a computer programming language to build web applications and sc...