Maruthi Krishna has Published 951 Articles

Is it possible to throw exception without using "throws Exception" in java?

Maruthi Krishna

Maruthi Krishna

Updated on 06-Sep-2019 11:02:55

3K+ Views

When an exception occurs in Java, the program terminates abnormally and the code past the line that caused the exception doesn’t get executed.To resolve this you need to either wrap the code that causes the exception within try catch ot, throw the exception using the throws clause. If you throw ... Read More

What happens when you declare a method/constructor final in Java?

Maruthi Krishna

Maruthi Krishna

Updated on 08-Aug-2019 13:23:52

336 Views

Whenever you make a method final, you cannot override it. i.e. you cannot provide implementation to the superclass’s final method from the subclass.i.e. The purpose of making a method final is to prevent modification of a method from outside (child class).Still, if you try to override a final method a compile ... Read More

How to find If a given String contains only letters in Java?

Maruthi Krishna

Maruthi Krishna

Updated on 07-Aug-2019 12:13:04

2K+ Views

To verify whether a given String contains only characters −Read the String.Convert all the characters in the given String to lower case using the toLower() method.Convert it into a character array using the toCharArray() method of the String class.Find whether every character in the array is in between a and ... Read More

What is the difference between Enumeration interface and enum in Java?

Maruthi Krishna

Maruthi Krishna

Updated on 07-Aug-2019 12:03:00

1K+ Views

Enum in Java is a datatype which stores a set of constant values. You can use these to store fixed values such as days in a week, months in a year etc.You can define an enum using the keyword enum followed by the name of the enumeration as −enum Days ... Read More

Comparing Strings with (possible) null values in java?

Maruthi Krishna

Maruthi Krishna

Updated on 07-Aug-2019 11:59:25

5K+ Views

Strings in Java represents an array of characters. They are represented by the String class.Using compareTo() methodThe compareTo() method of the String class two Strings (char by char) it also accepts null values. This method returns an integer representing the result, if the value of the obtained integer is −0: ... Read More

Can we add null elements to a Set in Java?

Maruthi Krishna

Maruthi Krishna

Updated on 07-Aug-2019 11:31:05

12K+ Views

A Set is a collection that cannot contain duplicate elements. It models the mathematical set abstraction.It does not allow duplicate elements and allow one null value at most.Set also adds a stronger contract on the behavior of the equals and hashCode operations, allowing Set instances to be compared meaningfully even ... Read More

How to convert Date to String in Java 8?

Maruthi Krishna

Maruthi Krishna

Updated on 07-Aug-2019 11:27:30

519 Views

The java.time package of Java provides API’s for dates, times, instances and durations. It provides various classes like Clock, LocalDate, LocalDateTime, LocalTime, MonthDay, Year, YearMonth etc. Using classes of this package you can get details related to date and time in much simpler way compared to previous alternatives.Java.time.LocalDate − This ... Read More

How to check Leap Year in Java 8 How to get current timestamp in Java 8?

Maruthi Krishna

Maruthi Krishna

Updated on 07-Aug-2019 11:25:49

768 Views

The java.time package of Java provides API’s for dates, times, instances and durations. It provides various classes like Clock, LocalDate, LocalDateTime, LocalTime, MonthDay, Year, YearMonth etc. Using classes of this package you can get details related to date and time in much simpler way compared to previous alternatives.Java.time.LocalDate − This ... Read More

How to represent fixed date like credit card expiry, YearMonth in java 8?

Maruthi Krishna

Maruthi Krishna

Updated on 07-Aug-2019 11:22:07

433 Views

The java.time package of Java provides API’s for dates, times, instances and durations. It provides various classes like Clock, LocalDate, LocalDateTime, LocalTime, MonthDay, Year, YearMonth etc. Using classes of this package you can get details related to date and time in much simpler way compared to previous alternatives.Java.time.LocalDate − This ... Read More

How to see if a date is before or after another date in Java 8?

Maruthi Krishna

Maruthi Krishna

Updated on 07-Aug-2019 11:20:25

927 Views

The java.time package of Java provides API’s for dates, times, instances and durations. It provides various classes like Clock, LocalDate, LocalDateTime, LocalTime, MonthDay, Year, YearMonth etc. Using classes of this package you can get details related to date and time in much simpler way compared to previous alternatives.Java.time.LocalDate − This ... Read More

Advertisements