Tutorialslot.com

youtube facebook twitter gmail pinterest

Objects in Java


Objects can be defined as the instance of a class.It can be called as a run-time entity. It has two major properties:
1)State - it denotes the value of the given object
2)Behaviour - it defines about the functionality of the given object

Initialization of objects:
Objects can be initialized with help of "new" operator. The new operator allocates memory dynamically for an object and returns a reference to it.The reference denotes the address of the memory location where the object is stored.

Syntax:
object_name = new class_name(arguments list);

For object declaration,
class_name object_name;

Example:
import java.util.Date;
class Date
{
  public static void main(String args[])
  {
      Date today = new Date();
      System.out.println(today);
  }
}

Output:
today



Advertisement Powered By Google Adsense






IF YOU LIKE THIS TUTORIALS PLEASE SHARE

Share on whatsapp

POPULAR TAGS

Java java tutorials learn java java programming tutorial learn java online learning java professionals tutorials Multithreading Generics Object Oriented Language Methods Polymorphism Inheritance