Maruthi Krishna has Published 951 Articles

What are parametrized constructors in Java?

Maruthi Krishna

Maruthi Krishna

Updated on 05-Feb-2021 10:35:49

13K+ Views

A constructor is similar to method and it is invoked at the time creating an object of the class, it is generally used to initialize the instance variables of a class. The constructors have same name as their class and, have no return type.Parameterized constructorsA parameterized constructor accepts parameters with ... Read More

What is the return type of a Constructor in Java?

Maruthi Krishna

Maruthi Krishna

Updated on 05-Feb-2021 10:32:03

5K+ Views

A constructor is similar to method and it is invoked at the time creating an object of the class, it is generally used to initialize the instance variables of a class. The constructors have same name as their class.Return type of a constructorA constructor doesn’t have any return type.The data ... Read More

What is the use of parametrized constructor in Java?

Maruthi Krishna

Maruthi Krishna

Updated on 05-Feb-2021 10:31:10

372 Views

A constructor is similar to method and it is invoked at the time creating an object of the class, it is generally used to initialize the instance variables of a class. The constructors have same name as their class and, have no return type.There are two types of constructors parameterized ... Read More

How to use regular expression in Java to pattern match?

Maruthi Krishna

Maruthi Krishna

Updated on 05-Feb-2021 10:27:49

196 Views

A regular expression is a string of characters that defines/forms a pattern to search an input text. A regular expression may contain one or more characters, using a regular expression you can search or replace a string.Java provides the java.util.regex package for pattern matching with regular expressions. The pattern class ... Read More

Is Java matcher thread safe in Java?

Maruthi Krishna

Maruthi Krishna

Updated on 05-Feb-2021 10:27:28

720 Views

A regular expression is a special sequence of characters that helps you match or find other strings or sets of strings, using a specialized syntax held in a pattern. They can be used to search, edit, or manipulate text and data. Java provides the java.util.regex package for pattern matching with ... Read More

What is a sub string in Java?

Maruthi Krishna

Maruthi Krishna

Updated on 05-Feb-2021 10:25:09

107 Views

The String class of the java.lang package represents set of characters. All string literals in Java programs, such as "abc", are implemented as instances of this class. A string index is an integer representing the position of each character in the string starting from zero.A substring is a part/segment of ... Read More

Do static variables get initialized in a default constructor in java?

Maruthi Krishna

Maruthi Krishna

Updated on 19-Nov-2020 15:41:03

6K+ Views

A static filed/variable belongs to the class and it will be loaded into the memory along with the class. You can invoke them without creating an object. (using the class name as reference). There is only one copy of the static field available throughout the class i.e. the value of ... Read More

Regular expression for a hexadecimal number greater than 10 and should be even in length in java.

Maruthi Krishna

Maruthi Krishna

Updated on 13-Jul-2020 13:15:09

291 Views

Following is the regular expression to match hexadecimal number greater than 10 with even length −^(?=.{10, 255}$)(?:0x)?\p{XDigit}{2}(?:\p{XDigit}{2})*$Where, ^ − Matches the starting of the sentence.(?=.{10, 255}$) − String ending with characters with 10 to 255.\p{XDigit}{2} − Two hexa-decimal characters.(?:\p{XDigit}{2})* − 0 or more sequences of double hexa-decimal characters.$ − Matches ... Read More

Types of quantifiers in Java regex

Maruthi Krishna

Maruthi Krishna

Updated on 13-Jul-2020 12:14:40

620 Views

If you want to specify the number of occurrences while constructing a regular expression you can use quantifiers. Java supports three types of quantifiers namely: greedy quantifiers, reluctant quantifiers and possessive quantifiers.Greedy quantifiers − Greedy quantifiers are the default quantifiers. A greedy quantifier matches as much as possible from the ... Read More

While chaining, can we throw unchecked exception from a checked exception in java?

Maruthi Krishna

Maruthi Krishna

Updated on 03-Jul-2020 08:32:08

637 Views

When an exception is cached in a catch block, you can re-throw it using the throw keyword (which is used to throw the exception objects).While re-throwing exceptions you can throw the same exception as it is with out adjusting it as −try {    int result = (arr[a])/(arr[b]);    System.out.println("Result ... Read More

Previous 1 ... 7 8 9 10 11 ... 96 Next
Advertisements