Found 7442 Articles for Java

What is static blank final variable in Java?

Syed Javed
Updated on 30-Jul-2019 22:30:22

471 Views

No. It is not allowed in Java. Compiler will fail the compilation throwing error that the blank final field may not have been initialized.

What is blank or uninitialized final variable in Java?

Ankitha Reddy
Updated on 30-Jul-2019 22:30:22

290 Views

No. It is not allowed in Java. The compiler will fail the compilation throwing error that the blank final field may not have been initialized.

What is blank or uninitialized final variable in Java?

Ankitha Reddy
Updated on 30-Jul-2019 22:30:22

290 Views

No. It is not allowed in Java. The compiler will fail the compilation throwing error that the blank final field may not have been initialized.

What are the 6 ways to use this keyword in Java?

Priya Pallavi
Updated on 18-Jun-2020 07:53:10

2K+ Views

this can be used to get the current object.this can be used to invoke current object's method.this() can be used to invoke current class constructorthis can be passed as a parameter to a method call.this can be passed as a parameter to a constructor.this can be used to return the current object from the method.

What are the 6 ways to use this keyword in Java?

Priya Pallavi
Updated on 18-Jun-2020 07:53:10

2K+ Views

this can be used to get the current object.this can be used to invoke current object's method.this() can be used to invoke current class constructorthis can be passed as a parameter to a method call.this can be passed as a parameter to a constructor.this can be used to return the current object from the method.

Can we create a program without a main method in Java?

Alshifa Hasnain
Updated on 18-Mar-2025 11:15:51

2K+ Views

Java is a statically typed, object-oriented programming language that needs a main method as an entry point for running. But it is possible to develop Java programs without a main method under certain conditions. Different Approaches The following are the different approaches for creating a program without a main method in Java − Using Static Blocks Using a Servlet Using a JavaFX Application Using Static Blocks (Before Java 7) In previous implementations of Java (prior to Java 7), a program was possible to run with a ... Read More

Can we create a program without a main method in Java?

Alshifa Hasnain
Updated on 18-Mar-2025 11:15:51

2K+ Views

Java is a statically typed, object-oriented programming language that needs a main method as an entry point for running. But it is possible to develop Java programs without a main method under certain conditions. Different Approaches The following are the different approaches for creating a program without a main method in Java − Using Static Blocks Using a Servlet Using a JavaFX Application Using Static Blocks (Before Java 7) In previous implementations of Java (prior to Java 7), a program was possible to run with a ... Read More

Java constructor return a value but, what?

Priya Pallavi
Updated on 04-Feb-2020 10:54:52

965 Views

No. Java constructor cannot return a value. If required, just create a method which calls the required constructor and returns the required value. See the example below.public class Tester {    public Tester(){}    public static Tester getInstance(){       Tester tester = new Tester();        return tester;    } }

Java constructor return a value but, what?

Priya Pallavi
Updated on 04-Feb-2020 10:54:52

965 Views

No. Java constructor cannot return a value. If required, just create a method which calls the required constructor and returns the required value. See the example below.public class Tester {    public Tester(){}    public static Tester getInstance(){       Tester tester = new Tester();        return tester;    } }

Java constructor return a value but, what?

Priya Pallavi
Updated on 04-Feb-2020 10:54:52

965 Views

No. Java constructor cannot return a value. If required, just create a method which calls the required constructor and returns the required value. See the example below.public class Tester {    public Tester(){}    public static Tester getInstance(){       Tester tester = new Tester();        return tester;    } }

Advertisements