answersLogoWhite

0

Maybe what you mean is method over loading. And that basically means that you can write different methods with the same name, which for example will allow you to call a method with few parameters, and let tat method fill the default values for the real thing.

Sample

private String my_method (String a, Integer b, SomethingElse c) {

do your stuff...

return "I did it";

}

private String my_method (String a) {

Integer defaultB = new Integer (5);

SomethingElse defaultC = new SomethingElse ();

return (my_method (a, defaultB, defaultC));

}

....

// You can call:

System.out (my_method("Who did that?"));

There is no concept of Method Overwriting in Java. We have Method overloading & method Overriding. Overloading is already explained.

If you are asking about Method Overriding pls read on... Overriding is a feature in Java where you can override (mask) the features of the parent class in the child class.

Lets say you have a method printName() in the parent class which prints the name of that class. When you extend this class in a child class if you call the method printName() the name of the parent would be displayed. Which you may want to change. If you want to display only the name of the child class then you can write the method printName() in the child class. On invocation the name of the child class would be printed.

Tip: If you want to display the name of the parent class somewhere you can invoke it by using super.printName() because once you override that method in the child class you cannot access the parent class method directly.

User Avatar

Wiki User

16y ago

What else can I help you with?

Related Questions

Why should the java main method has the return type as void?

A void method is one that returns no value. The Java main() method is the first method to be called, therefore it doesn't need to return a value to another Java method, therefore it is declared as void. If something needs to be returned to the operating system, this is done differently, not by "returning a value" in the sense of Java.


Why main is used in java?

In java need main() method. without main() in java we won't run the java programe main() signals the entry point to the program - it tells the Java Virtual Machine which is the first program that should be executed.


Where can you go to download Java?

Check the related links below to various links to get different versions of Java. For the basic user the first link will get you what you need to load web pages using Java.


Is it possible to define a java static method inside a main method?

Because, the main method is the starting point of the java program and if we need an object of that class even before the main can be invoked, it is not possible. Hence it is declared static so that the JVM Can acess the main method without having to instantiate that particular class


If application can be run without main what need of main method?

Well, if an application could be run without a main method, then you would not need it. However, Java applications cannot run if they do not contain a main method.


The Java method printf is based on the?

Java doesn't have a printf method. To provide the implementation of printf method of C in java, the java has two print methods. They are1. print()2. println()The first method prints the text in braces on the same line, while the second is used to print on the next line. In fact, ln in println() stands for next line. We need not use /n while working in java.Actually, the System.out.format() function is practically identical to printf in C. When translating code from C to Java, you can generally replace all calls to printf(args...) with calls to System.out.format(args...)....and to answer the original question, Java's System.out.format() method is based off of C's printf() function.


When wil you need throws keyword in java?

The throws keyword will be used in method declaration to signify the fact that, some pieces of code inside the method may throw exceptions that are specified in the method signature.


How do you program a reverse auto loan calculator in JAVA?

In order to program a reverse auto loan calculator in JAVA, you are going to need a lot of experience with JAVA. There are online tutorials that can help you set up with fundamentals of JAVA so that you will be able to create almost any basic program you want.


How to write java program without using main method?

Java program without mainWe need a main method for executing a program.But YES we can write a program without using main() method.TRICK 1 of 2 :: while writing applets in java we don't use main... we use init() method instead.TRICK 2 of 2 :: using 'static' we can write a program whic will execute successfully and output the desired message on screen. Here it is :: class Mohit{ static { System.out.println("This java program has run without the main method"); System.exit(0); } } -->save the program as Mohit.java to compile::javac Mohit.java (in command prompt) to run ::java Mohit(command prompt) output will be ::This java program has run without the main methodWhoa!!!!! we are done.;)


Which the best programming language between java and visual basic?

Java. While Visual Basic is certainly useful for writing Windows applications, that's all it can do. If you want the same program to run on other platforms (such as Linux), the entire program must be re-written from scratch. With Java, there is no need to convert. Once compiled, Java programs can be executed upon any platform that has a suitable Java virtual machine implementation, which is pretty much everything today.


Why use void in main of java?

No. void is not a data type. It is mandatory for all java methods to return something and if it is not going to return anything, we have to mark the method with a "void" return type to let the JVM know that it must not expect anything from the method.


What powder game doesnt need java?

Any program written for the Java technology needs Java. Any program NOT written for Java DOESN'T need it.