

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
What is the object class in Java?
The java.lang.Object class is the root of the class hierarchy. Every class has Object as a superclass. All objects, including arrays, implement the methods of this class.
Example
Following example demonstrates the usage of the Object class. Here we are getting the name of the current class using the getClass() method.
import java.util.GregorianCalendar; public class ObjectDemo { public static void main(String[] args) { //Create a new ObjectDemo object GregorianCalendar cal = new GregorianCalendar(); //Print current time System.out.println("" + cal.getTime()); //Print the class of cal System.out.println("" + cal.getClass()); //Create a new Integer Integer i = new Integer(5); //Print i System.out.println("" + i); //Print the class of i System.out.println("" + i.getClass()); } }
Output
Sat Sep 22 00:31:24 EEST 2012 class java.util.GregorianCalendar 5 class java.lang.Integer
- Related Questions & Answers
- Why Object class is the super class for all classes in Java?
- What is the class "class" in Java?
- Object class in Java
- What is the Thread class in Java?
- What is the root class in Java?
- What is the super class of every class in Java?
- Object class in java programming
- Object and class in Java
- What is Java String Class?
- What is AbstractSequentialList class in Java?
- What is AbstractCollection class in Java?
- What is AbstractList Class in Java?
- What is object cloning in Java?
- What is the difference between Component class and Container class in Java?
- What is the difference between a class and an object in C#?
Advertisements