Narasimha Murthi

Narasimha Murthi

13 Articles Published

Articles by Narasimha Murthi

Page 2 of 2

Can we override final methods in Java?

Narasimha Murthi
Narasimha Murthi
Updated on 30-Jun-2020 2K+ Views

Overriding is a one of the mechanisms to achieve polymorphism. This is the case when we have two classes where, one inherits the properties of another using the extends keyword and, these two classes same method including parameters and return type (say, sample).Since it is inheritance. If we instantiate the subclass a copy of superclass’s members is created in the subclass object and, thus both methods are available to the subclass.When we invoke this method (sample) JVM calls the respective method based on the object used to call the method.Overriding final methodsNo, you cannot override final method in java. If ...

Read More

Java.util.StringJoiner in Java8

Narasimha Murthi
Narasimha Murthi
Updated on 29-Jun-2020 187 Views

This class is used Join a sequence of characters separating using the delimiter.Examplepublic class StringJoinerSample { public static void main(String[] args){ StringJoiner sj = new StringJoiner(", "); sj.add("Krishna"); sj.add("Raju"); sj.add("Satish"); sj.add("Pruthvi"); System.out.println(sj); } }OutputKrishna, Raju, Satish, Pruthvi

Read More

What is the difference between object and reference in java?

Narasimha Murthi
Narasimha Murthi
Updated on 29-Jun-2020 11K+ Views

A class in a blue print/user defined datatype in java that describes the behavior/state that the object of its type support.Examplepublic class Student {    String name "Krishna";    int age = 20;    void greet() {       System.out.println("Hello how are you");    } }An object is an instance of a class created from it using the new keyword. Once you create an object of a class, using it you can access he members of the class. In the below given code an object of the class Student is created.public class Example {    public static void main(String ...

Read More
Showing 11–13 of 13 articles
« Prev 1 2 Next »
Advertisements