Why does everything have to be in a class ?

Java is an object-oriented(00) language. It’s not Iike the old days
when you had steam driven compilers and wrote one monolithic source
file with a pile of procedures.
What is method and instance variable ?

Things an object knows about itself are called instance variable.
While Things an object can do are called methods.
What’s the difference between a class and an object?

A class is blueprint for an object . It tells JVM how to make an
object of that perticular type. Each object made from that class
can have its own values for the instance variables of that class.
Identify who am I ?

I am compiled from a .java file. : class
My instance variable values can be different from my buddy’s values. : object
I behave like a template. : class
I like to do stuff. : object, method
I can have many methods. : class,object
I represent ‘state’. : instance variable
I have behaviors. : object,class
I am located in objects. : method, instance variable
I live on the heap. : object
I am used to create object instances. : class
My state can change.: object,instance variable
I declare methods. : class
I can change at runtime. : object, instance variable
What happens if the argument you want to pass is an object instead of a primitive?

Java passes everything by value. Everything. But…value means bits
inside the variable. And remember, you don’t stuff objects into variables;
the variable is a remote control – a reference to an object. So, if you pass a
reference to an object into a method, you’re passing a copy of the remote control.
Can a method declare multiple return values? Or Is there some way to return more than one value?

Sort of.A method can declare only one return value. BUT… If you want to return, say, three int values,
then the declared return type can be an Int array. Stuff those ints into the array,and passIt on back. It’s
a little more involved to return multiple values with different types.
Some basics about java

1. Real-world objects contain state and behavior.
2. A software object’s state is stored in fields.
3. A software object’s behavior is exposed through methods.
4. Hiding internal data from the outside world, and accessing it only through publicly exposed methods is known as data encapsulation.
5. A blueprint for a software object is called a class.
6. Common behavior can be defined in a superclass and inherited into a subclass using the extends keyword.
7. A collection of methods with no implementation is called an interface.
8. A namespace that organizes classes and interfaces by functionality is called a package.
9. The term API stands for Application Programming Interface.

Reverse string in Java.

Simplest Example of making reverse string using java…

public class StringReverse
  public static void main(String[] args)
  String string=args[0];
  String reverse = new StringBuffer(string).
  System.out.println("\nString before reverse:
  System.out.println("String after reverse: