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.




No comments:

Post a Comment