1.

Determining The Class Object?

Answer»

Following methods of Class class is USED to DETERMINE the class object: 

  1. Public Boolean is Interface (): determines if the specified Class object represents an interface type. 
  2. Public Boolean isArray (): determines if this Class object represents an array class. 
  3. Public Boolean is Primitive (): determines if the specified Class object represents a primitive type. 

Let's see the SIMPLE example of reflection api to determine the object type.

class Simple{}

interface My{}

class TEST{

public static void main(STRING args[]){

try{

Class c=Class.forName("Simple");

System.out.println(c.is Interface());

Class c2=Class.forName("My");

System.out.println(c2.is Interface());

}catch(Exception e){System.out.println(e);}

}

}

Output:

false

true

Following methods of Class class is used to determine the class object: 

Let's see the simple example of reflection api to determine the object type.

class Simple{}

interface My{}

class Test{

public static void main(String args[]){

try{

Class c=Class.forName("Simple");

System.out.println(c.is Interface());

Class c2=Class.forName("My");

System.out.println(c2.is Interface());

}catch(Exception e){System.out.println(e);}

}

}

Output:

false

true



Discussion

No Comment Found