- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- 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 Articles
- What is the class "class" in Java?
- Object class in Java
- Why Object class is the super class for all classes in Java?
- Object and class in Java
- Object class in java programming
- What is the root class in Java?
- What is the Thread class in Java?
- What is the super class of every class in Java?
- Method of Object class in Java
- How static class Object is created without reference of outer class in java?
- What is AbstractSequentialList class in Java?
- What is AbstractCollection class in Java?
- What is AbstractList Class in Java?
- Listing the Modifiers of a Class Object in Java
- Difference between Object and Class in Java

Advertisements