Type Casting in Java – Implicit and Explicit Casting

Type Casting in Java is  nothing but converting a primitive or interface or class in Java into other type. There is a rule in Java Language that classes or interface which shares the same type hierrachy only can be typecasted. If there is no relationship between then Java will throw ClassCastException. Type casting are of two types they are

  1. Implicit Casting (Widening)
  2. Explicit Casting (Narrowing)

[Read more…]

Taking Command Line Arguments in Java

The command line argument is the argument which is passed at the time of running a Java application. Java can take any number of arguments from the command-line,  You could see that there will be String args[] used in the declaration of the main() method, which tells us that Java can takes all the argument which is passed in the command-line as String, but the question here is that how to pass the command-line argument to Java.  [Read more…]

Object and Object Class in Java

What is an Object in Java ?

We all know that Java is an Object Oriented Programming Language, which entirely rely on Objects and Classes. Any entity which has State and Behavior is known as Object, for example note, pen, bike, book etc. It can be either physical or logical. All the objects should have the below two characteristics

  1. State : State represents the bof the objects, Lets take car as example car has name, color, engine etc.
  2. Behavior : Behavior represents the functionality of that object. With car you can drive, apply breaking, change gear etc.

[Read more…]