InterviewSolution
| 1. |
Determining The Class Object? |
|
Answer» 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 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 |
|