Please note, this is a STATIC archive of website www.tutorialspoint.com from 11 May 2019, cach3.com does not collect or store any user information, there is no "phishing" involved.
Tutorialspoint
Cover Image
Cover Image
Drag to reposition
Contributed Answers

Get Hash Code for Integer in Java

Answered on 19th Feb, 2019, 0 Views

The HashCode for an Integer can be obtained using the hashCode() method in Java. This method does not accept any parameters and it returns a hash code value of the Integer object. A program that demonstrates the hashCode() method in Java is given as follows:  Live Demo , , Now let us understand the above program. The Integer i is defined. Then the Integer value is printed and its HashC.....

Static import the Math Class Methods in Java

Answered on 19th Feb, 2019, 0 Views

Static import means that the fields and methods in a class can be used in the code without specifying their class if they are defined as public static. The Math class method sqrt() in the package java.lang is static imported. A program that demonstrates this is given as follows:  Live Demo , , Now let us understand the above program. The Math class is not required along with the method.....

Multiple inheritance by Interface in Java

Answered on 15th Feb, 2019, 0 Views

An interface contains variables and methods like a class but the methods in an interface are abstract by default unlike a class. Multiple inheritance by interface occurs if a class implements multiple interfaces or also if an interface itself extends multiple interfaces. A program that demonstrates multiple inheritance by interface in Java is given as follows:  Live Demo , , Now let us.....

Use a quantifier to find a match in Java

Answered on 15th Feb, 2019, 0 Views

One of the quantifiers is the plus(+). This matches one or more of the subsequence specified with the sequence. A program that demonstrates using the quantifier plus(+) to find a match in Java is given as follows:  Live Demo , , Now let us understand the above program. The subsequence “o+” is searched in the string sequence "o oo ooo". Then the find() method is used to find.....

Demonstrate Private access modifier in Java

Answered on 15th Feb, 2019, 0 Views

The data members and methods of a class can be accessed only from within their declared class if they are specified with the private access modifier. The keyword private is used to specify this modifier. A program that demonstrates the private access modifier in Java is given as follows:  Live Demo , , Now let us understand the above program. The class A has a private data member a tha.....

Zip Code validation using Java Regular Expressions

Answered on 15th Feb, 2019, 0 Views

The zip code can be validated using the java.util.regex.Pattern.matches() method. This method matches the regular expression for the zip code and the given input zip code and returns true if they match and false otherwise. A program that demonstrates this is given as follows:  Live Demo , , Now let us understand the above program. The zip code is printed. The Pattern.matches() method m.....

Class that contains a String instance variable and methods to set and get its value in Java

Answered on 15th Feb, 2019, 0 Views

A class declaration can contain a String instance and methods to set and get its value in Java. A program that demonstrates this is given as follows:  Live Demo , , Now let us understand the above program. The Name class is created with a data member name and member functions setName() and getName() that set and get its value respectively. A code snippet which demonstrates this is as f.....

Demonstrate constructors in a Multilevel Hierarchy in Java

Answered on 15th Feb, 2019, 0 Views

Multilevel inheritance is when a class inherits a class which inherits another class. An example of this is class C inherits class B and class B in turn inherits class A. A program that demonstrates constructors in a Multilevel Hierarchy in Java is given as follows:  Live Demo , , Now let us understand the above program. The class A contains the constructor A(). The class B uses the ex.....

Create class Objects in Java using new operator

Answered on 15th Feb, 2019, 0 Views

Class objects can be created in Java by using the new operator. A class is instantiated by the new operator by allocating memory for the object dynamically and then returning a reference for that memory. A variable is used to store the memory reference. A program that demonstrates this is given as follows:  Live Demo , , Now let us understand the above program. The Student class is cre.....

Add elements at the end of a Vector in Java

Answered on 15th Feb, 2019, 0 Views

Elements can be added at the end of a Vector using the java.util.Vector.add() method. This method has a single parameter i.e. the element to be added. It returns true if the element is added to the Vector as required and false otherwise. A program that demonstrates this is given as follows:  Live Demo , , Now let us understand the above program. The Vector is created. Then Vector.add().....

loader
Advertisements
Contribution

We use cookies to provide and improve our services. By using our site, you consent to our Cookies Policy.