Anvi Jain

Anvi Jain

427 Articles Published

Articles by Anvi Jain

Page 18 of 43

Get the Component Type of an Array Object in Java

Anvi Jain
Anvi Jain
Updated on 11-Mar-2026 2K+ Views

In order to get the component type of an Array Object in Java, we use the getComponentType() method. The getComponentType() method returns the Class denoting the component type of an array. If the class is not an array class this method returns null.Declaration − The java.lang.Class.getComponentType() method is declared as follows -public Class getComponentType()Let us see a program to the get the component type of an Array Object in Java -Examplepublic class Example {    public static void main(String[] args) {       int[] array = new int[] {1, 2, 3};       // obtain the Class of ...

Read More

Demonstrate getting the immediate superclass information in Java

Anvi Jain
Anvi Jain
Updated on 11-Mar-2026 204 Views

The immediate superclass information of any entity such as an object, class, primitive type, interface etc. can be obtained using the method java.lang.Class.getSuperclass().A program that demonstrates this is given as follows −Examplepackage Test; import java.lang.*; class Class1{ } class Class2 extends Class1{ } public class Demo { public static void main(String args[]) { Class1 obj1 = new Class1(); Class2 obj2 = new Class2(); Class c; c = obj2.getClass(); ...

Read More

Prove that the interface for a primitive type is an empty array in Java

Anvi Jain
Anvi Jain
Updated on 11-Mar-2026 198 Views

The getInterfaces() method is used to prove that the interface for a primitive type is an empty array. A program that demonstrates this is given as follows −Examplepackage Test; import java.util.*; public class Demo {    public static void main(String[] args) {       Class c = int.class;       Class[] interfaces = c.getInterfaces();       System.out.println("The Interface is: " + Arrays.asList(interfaces));    } }OutputThe Interface is: []Now let us understand the above program.The int.class is a reference to the Class object for the primitive type int. The interface for this is determined using the getInterfaces() method. ...

Read More

How to call Private Constructor in Java

Anvi Jain
Anvi Jain
Updated on 11-Mar-2026 1K+ Views

The method java.lang.Class.getDeclaredConstructor() can be used to obtain the constructor object for the private constructor of the class. The parameter for this method is a Class object array that contains the formal parameter types of the constructor.A program that demonstrates this is given as follows −Examplepackage Test; import java.lang.reflect.*; public class Demo {    String str;    Double d;    public Demo(String str, Double d) {       this.str = str;       this.d = d;    }    public static void main(String[] args) {       try {          Demo obj = new ...

Read More

Get the name of a primitive type in Java

Anvi Jain
Anvi Jain
Updated on 11-Mar-2026 2K+ Views

The getName() method is used to get the names of the entities such as primitive type, interface, class, array class, void etc. that represented by the class objects. These names are returned in the form of a string.A program that gets the name of a primitive type using getName() method is given as follows -Examplepublic class Demo {    public static void main(String[] argv) throws Exception {       String name1 = float.class.getName();       System.out.println(name1);       String name2 = int.class.getName();       System.out.println(name2);       String name3 = char.class.getName();       System.out.println(name3); ...

Read More

Add Red label with Bootstrap

Anvi Jain
Anvi Jain
Updated on 11-Mar-2026 628 Views

Use .label-danger class in Bootstrap to add red colored label.You can try to run the following code to implement the .label-danger class −Example           Bootstrap Example                                          If you find any issues, click below          Danger          

Read More

Add green label (stating success) with Bootstrap

Anvi Jain
Anvi Jain
Updated on 11-Mar-2026 314 Views

Use .label-success class in Bootstrap to add green label.You can try to run the following code to implement the .label-success class −Example           Bootstrap Example                                          Success label          Success          

Read More

Bootstrap .btn-success class

Anvi Jain
Anvi Jain
Updated on 11-Mar-2026 551 Views

To set a successful action in Bootstrap, use the .btn-success class.You can try to run the following code to implement btn-success class in Bootstrap −Example        Bootstrap Example                                       Success Button    

Read More

Set small modal in Bootstrap

Anvi Jain
Anvi Jain
Updated on 11-Mar-2026 1K+ Views

Use the .modal-sm class in Bootstrap to set small modal with less width.You can try to run the following code to implement the .modal-sm class −Example           Bootstrap Example                                          Examination          Result                                                                              ×                      Warning                                                          If JavaScript isn't enabled in your web browser, then you may not be able to see the result.                                                          Close                                                                  

Read More

Container for checkboxes in Bootstrap

Anvi Jain
Anvi Jain
Updated on 11-Mar-2026 623 Views

Add checkbox to a web page with Bootstrap, using the .checkbox class in BootstrapYou can try to run the following code to set container for checkboxes −Example           Bootstrap Example                                          Programming Survey          Which programming languages do you like?                                      Java                                        C++                                        C                                

Read More
Showing 171–180 of 427 articles
« Prev 1 16 17 18 19 20 43 Next »
Advertisements