Wednesday, March 12, 2014

what is java

What is java?
Java is simple,Object Oriented and Platform independent.

Java Basic Syntax:
Object - Objects have state and behaviors.An object is an instance of a class.
Example;- A bird has states-color,name as well as behaviors eating
Class - A class can be defined as a template/ blue print that describe the behaviors.
Method - A class contain many method. it is in where the logic are written,data is manipulated and all the actions are executed.
Instant Variables - Each object has its unique set of instant variables. an object`s state is created by values assigned assigned to these instant variables.

First java Program:-
public class MyFirstJavaProgram {
public static  void main(String []args) {
System.out.println("Hello");//print hello word
}
}

Thursday, September 12, 2013

Collection framework

Collection Framework:- Collection is a well design set. if classes and interface are sorting and manipulating a group of data as a single unit is called collection. OR          A set of classes and interfaces which can be used for representing a group of object as single is called Collection Framework.

Collections :- Collection is an utility classes to define several utility methods for collection implemented class object.

Basic interface of collection classes are
1). List
2). Set
List is an ordered collection and it contain duplicate value.
Set is an  collection that doesn`t contain duplicate value.

Q. What is difference between array and collection?
A.  Array is fixed in size one`s we initialize then we can`t increase or decrease at the time of requirement. but Collection is growable in nature hence the requirement it can be increase or decrease.
At memory point of view Array is not recommended but Collection is recommended.
At performance point of view Array is recommended to used But Collection is not Recommended. 

Monday, August 19, 2013

JDBC

What is difference between Database and DBMS?

Database is a collection of interrelated data. Database Management system is a software which can be use manage the data by sorting it on the database.

How could be executed when we send a query to Database?

Database engine take the following step
  • Query Tokenization
  • Query Passing
  • Query Optimization
  • Query Execution

What is JDBC drivers?

JDBC drivers are processes  of interaction with database and java application.

How many types of JDBC drivers?

There are 
  • JDBC-ODBC Driver
  • Native Driver
  • Middel-ware Driver
  • Pure Java Driver

What is JDBC and what are the step write JDBC application?

The process of interacting with database from a java application is called JDBC.
To interacting with database from java application we use following steps..

  1. Load and register driver
  2. Establish connection between a java application and the database
  3. Prepare either statement object or prepare statement or callable statement object as per the application requirement.
  4. Write and execute sql queries. 
  5. Terminate the connection which we have established.


How to execute SQL Queries from a java application?

To execute the sql queries we will use the following methods from Statement object.

  • st.executeQuery(....)
  • st.executeUpadte(....)
  • st.execute(.....)

What are the difference between executeQuery(), executeUpdate() and execute() methods?

execute() :- When we use selection group sql with the execute() then we will get Resultset object at heap memory with the fetched data.
public boolean execute(String sql Query)
executeUpdate() :-  Where executeUpdate() can be used to execute group of sql query to update the database.
public int executeUpdate(String sql query)
executeQuey():- where executequery() can be used to execute selection group sql queries to fetch the data from database.
public ResultSet executeQuery(sql statement)

What is ment by ResultSet object?

ResultSet is an Object which can be used to maintain the fetched data from database in the JDBC application.

What is result set MetaDeta?

Data about data is called metadata. Similarly data about data available in the result set object  is called Result set Meta Data.


What is prepared statement and when we used ?

Prepared statement retain pre-compile SQL statements.Same optimization query will be used for new parameter value. and it is used in when same query will fire with different value of parameter.


What is Statement ?

Statement is doesn`t retain pre-compile sql statement .query will be optimized & complied object again & again if parameter value are changed.

Tuesday, August 13, 2013

Core JAVA


 Java is Object Oriented Language.It is introduce by sun Microsystem in 1995. It is platform independent language. Java doesn`t support pointer.It is  support abstraction, Polymorphism,Encapsulation etc.This is the entry point of our java program.The main method has to have this exact signature in order to be able to run our program.

Public:-again means that anyone can access it.
Static:-means that you can run this method without creating an instance of Main
Void:-means that this method doesn`t return any value.
Main:- is this name of the method.
The arguments we inside the method are the arguments that we will get when running the program with parameters.It`s an array of strings. we will use it in our next lesson, so don`t worry if you don`t understand it all now.

What is String?

String is a class. Which is contain in java.lang package and we can take String as a data type also.

How many way to define String?

  1. String s1 = "abc";
  2. String s2 = new String("abc");
In First Statement assignment operator is used to assign to string and it is a stored in the String pool. In this case jvm check the string pool if it find same value then it create references to it and if not available then create it.
In the second statement each and very time it create a new object of String class. 

What is String Constant pool or String letrial pool ?

It is a seprate block of memory where the string object is store.

How to add two String?

We can add two string with "+" operator or concat() Method of String class.

How to make a String immutable?

  • Make a class final or  private
  • allow only getter method in class

What is wrapper classes?

Wrapper class are used to covert primitive data types into object.
for eg.
int kp = 2;
Integer wpc =  new Integer(kp);
The int data type k is converted into an object.