Home » Java programming language

Java Object Class final Class getClass() method with Example

Java Object class final Class getClass() method: Here, we are going to learn about the final Class getClass() method of Object class with its syntax and example.
Submitted by Preeti Jain, on June 28, 2019

Object Class final Class getClass()

  • This method is available in java.lang.Object.getClass().
  • This method is used to returns the Class class object.
  • The returned Class object is the object that is locked by static synchronized methods of the given class.
  • This method is final so we can't override it.

Syntax:

    final Class getClass(){
    }

Parameter(s):

We don't pass any object as a parameter in the method of the Object class.

Return value:

The return type of this method is Class that means this method returns Class object.

Java program to demonstrate example of Object Class getClass() method

import java.lang.Object;

public class ObjectClass {

    // Java program to demonstrate working of 
    // getClass() method of Object class

    public static void main(String[] args) {
        Float fl = new Float(10.f);
        Class cl = fl.getClass();
        System.out.println("The name of Class of Float fl is : " +
            cl.getName());
    }
}

Output

D:\Programs>javac ObjectClass.java

D:\Programs>java ObjectClass
The name of Class of Float fl is : java.lang.Float





Comments and Discussions

Ad: Are you a blogger? Join our Blogging forum.
Learn PCB Designing: PCB DESIGNING TUTORIAL




Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing
» Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates


© https://www.includehelp.com some rights reserved.