List the Interfaces that an Interface Extends in Java

Krantik Chavan
Updated on 25-Jun-2020 12:27:52

439 Views

The interfaces that are implemented by an interface that is represented by an object can be determined using the java.lang.Class.getInterfaces() method. This method returns an array of all the interfaces that are implemented by the interface.A program that demonstrates this is given as follows −Example Live Demopackage Test; import java.lang.*; import java.util.*; public class Demo {    public static void main(String[] args) {       listInterfaces(java.util.List.class);    }    public static void listInterfaces(Class c) {       System.out.println("The interface is: " + c.getName());       Class[] interfaces = c.getInterfaces();       System.out.println("The Interfaces are: " + Arrays.asList(interfaces)); ... Read More

Math.log2 Function in JavaScript

Samual Sam
Updated on 25-Jun-2020 12:27:45

82 Views

The log2() function of the Math object accepts a number and returns the natural logarithm (base 2) of the given number.SyntaxIts Syntax is as followsMath.log2(48);Example Live Demo    JavaScript Example           var result = Math.log2(48);       document.write("Result: "+result);     OutputResult: 5.584962500721156

Check Whether String is an Interface or Class in Java

Nancy Den
Updated on 25-Jun-2020 12:27:18

641 Views

The method java.lang.Class.isInterface() is used to find if String is an interface or class in Java. This method returns true if String is an interface, otherwise it returns false.A program that demonstrates this is given as follows −Example Live Demopackage Test; import java.lang.*; public class Demo {    public static void main(String[] args) {       Class c = String.class;       boolean interfaceFlag = c.isInterface();       System.out.println("This is an Interface? " + interfaceFlag);    } }OutputThis is an Interface? falseNow let us understand the above program.The isInterface() method is used to find if String is an ... Read More

Compare Two Char Arrays in a Single Line in Java

Smita Kapse
Updated on 25-Jun-2020 12:26:39

4K+ Views

Two char arrays can be compared in Java using the java.util.Arrays.equals() method. This method returns true if the arrays are equal and false otherwise. The two arrays are equal if they contain the same number of elements in the same order.A program that compares two char arrays using the Arrays.equals() method is given as follows −Example Live Demoimport java.util.Arrays; public class Demo {    public static void main(String[] argv) throws Exception {       boolean flag = Arrays.equals(new char[] { 'a', 'b', 'c' }, new char[] { 'a', 'b', 'c' });       System.out.println("The two char arrays are equal? ... Read More

Math.acosh() Function in JavaScript

Samual Sam
Updated on 25-Jun-2020 12:26:11

71 Views

The acosh() function of the Math object accepts a number and returns its hyperbolic arc cosine value in radians. To convert the resultant value into degrees, multiply it with 180 and divide the result by 3.14159 (pi value).SyntaxIts Syntax is as followsMath.acosh(0.5)Example Live Demo    JavaScript Example           var result = Math.acosh(90);       document.write("Hyperbolic arccosine value: "+result);       document.write("");       document.write("Hyperbolic arccosine value in degrees: "+result*180/Math.PI);     OutputHyperbolic arccosine value: 5.192925985263684 Hyperbolic arccosine value in degrees: 297.5327422794238

List Interfaces Implemented by a Class in Java

Krantik Chavan
Updated on 25-Jun-2020 12:26:04

683 Views

The interfaces that are implemented by a class that is represented by an object can be determined using the java.lang.Class.getInterfaces() method. This method returns an array of all the interfaces that are implemented by the class.A program that demonstrates this is given as follows −Example Live Demopackage Test; import java.lang.*; import java.util.*; public class Demo {    public static void main(String[] args) {       listInterfaces(String.class);    }    public static void listInterfaces(Class c) {       System.out.println("The Class is: " + c.getName());       Class[] interfaces = c.getInterfaces();       System.out.println("The Interfaces are: " + Arrays.asList(interfaces)); ... Read More

Math.asinh() Function in JavaScript

karthikeya Boyini
Updated on 25-Jun-2020 12:25:44

74 Views

The asinh() function of the Math object accepts a number and returns its hyperbolic arc sine value in radians. To convert the resultant value into degrees, multiply it with 180 and divide the result by 3.14159 (pi value).SyntaxIts Syntax is as followsMath.asinh(0.5)Example Live Demo    JavaScript Example           var result = Math.asinh(90);       document.write("Hyperbolic arcsine value: "+result);       document.write("");       document.write("Hyperbolic arcsine value in degrees: "+result*180/Math.PI);     OutputHyperbolic arcsine value: 5.192987713658941 Hyperbolic arcsine value in degrees: 297.53627905594817

Prove the Interface for a Primitive Type is an Empty Array in Java

Anvi Jain
Updated on 25-Jun-2020 12:25:30

164 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 −Example Live Demopackage 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() ... Read More

Math atanh Function in JavaScript

Samual Sam
Updated on 25-Jun-2020 12:25:19

80 Views

The atanh() function of the Math object accepts a number and returns its hyperbolic arc arctangent value in radians. To convert the resultant value into degrees, multiply it with 180 and divide the result by 3.14159 (pi value).SyntaxIts Syntax is as followsMath.atanh(0.5)Example Live Demo    JavaScript Example           var result = Math.atanh(0.5);       document.write("arctangent value: "+result);       document.write("");       document.write("hyperbolic arctangent value in degrees: "+result*180/Math.PI);     Outputarctangent value: 0.5493061443340548 arctangent value in degrees: 31.47292373094538

Catalan Numbers in Java

Arjun Thakur
Updated on 25-Jun-2020 12:25:10

760 Views

The nth Catalan number in terms of binomial coefficients is calculated by the formula(n + k )/k where k varies from 2 to n and n ≥ 0. i.e.Cn = (2n)!/((n+1)!n!)Programpublic class CatalanNumbers {    public static long fact(int i) {       if(i

Advertisements