Java Class getSuperClass() Method21 Mar 2025 | 1 min read The getSuperClass() method of java Class class gets the superclass of this class. If no superclass exists then null is returned. SyntaxParameterNA ReturnsImmediate superclass of the class ThrowsNA Example 1Output: objsup1 is object of type = ClassgetSuperClassExample1 super class of objsup1 = java.lang.Object Example 2Output: objsup1 is object of type = Basecls super class of objsup1 = Supercls Next TopicJava Class |
Java Class Method The getDeclaredConstructoe() method of java Class class returns a constructor object representing all the constructors present in the class. Syntax public Constructor<T> getDeclaredConstructor(Class<?>... parameterTypes) throws NoSuchMethodException, SecurityException Parameter parameterTypes - the parameter array Returns Constructor object. Throws NoSuchMethodException , SecurityException Example 1 import java.lang.reflect.Constructor; public class ClassgetDeclaredConstructorExample1 { ...
2 min read
Java Class Method The method of java Class class returns a Constructor object that reflects the public constructor of the class. Syntax public Constructor<T> getConstructor(Class<?>... parameterTypes) throws NoSuchMethodException, SecurityException Parameter parameterTypes - the parameter array. Returns Constructor object. Throws NoSuchMethodException , SecurityException Example 1 //import statements import java.lang.reflect.*; public class ClassgetConstructorExample1 { public...
2 min read
Java Class Method The method of java Class class returns an array which contains the constructor object reflected by the public constructors of this class. If no constructor is defined, it returns an array of length 0. Syntax public Constructor<?>[] throws SecurityException Parameter NA Returns An array of all...
2 min read
Java Class () Method The () method of java Class returns the class representing the component type of an array. Otherwise this method return null. Syntax public Class<?> () Parameter NA Returns Class representing the component type. Throws This does not throw an exception. Example 1 //import statements import java.lang.*; public class ClassExample1 { public...
1 min read
Java Class Method The method of java Class class gets the annotation by type that is associated with this element. If no annotation is related to this element, it returns an array of length 0. Syntax public <A extends Annotation> A[] getAnnotationsByType(Class<A> annotationClass) Parameter annotationClass - the Class...
2 min read
Java Class Method The method of java Class class returns an array of constructor objects representing all the constructors defined in this class object. If no constructor is declared, then it returns an array of length 0. Syntax public Constructor<?>[] ]throws SecurityException Parameter NA Returns An array of constructor object. Throws SecurityException Example...
2 min read
Java Class Method The method of java Class class checks if the specified class object represents interface or not. If not then return false. Syntax public boolean Parameter NA Returns true if this object represents an interface; false otherwise. Throws NA Example 1 import java.lang.*; public class ClassisInterfaceExample1 { public static void...
1 min read
Java Class Method The method of java Class class checks if the specified object can be assigned to object represented by that class, i.e., if both the objects are an instance of the same class or not. Syntax public boolean isInstance(Object obj) Parameter obj - the object to...
1 min read
Java Class Method The method of java Class class returns this element's annotation for the specified type if any annotation is directly present otherwise null. Syntax public <A extends Annotation> A getDeclaredAnnotation(Class<A> annotationClass) Parameter annotationClass - the Class object corresponding to the annotation type Returns annotation for the specified annotation...
2 min read
Java Class Method The method of java Class class returns the canonical name of the class as defined by the Java Language Specification. Otherwise, it returns Null. Syntax public String Parameter No parameter is passed. Returns The canonical name of the underlying class if it exists, otherwise Null. Throws Does not...
1 min read
We request you to subscribe our newsletter for upcoming updates.
We provides tutorials and interview questions of all technology like java tutorial, android, java frameworks
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India