OOPS Through JAVA
1. Program for printing the roots of Quadratic equation
Description:
In this program we are finding the roots of the quadratic equation. Dependsupon the value of the determinant we are printing the nature as well as thecorresponding roots. The particular part is explained below:
public static void main ( String args[] ) :
Every program begins with the main() method. All the Java applications begin execution by calling main(). The full meaning of each part of this is:
public:
The
public
keyword is an access specifier, which allows the programmer tocontrol the visibility of class members. When a class member is preceded by
public,
then that member may be accessed by code outside the class in which it isdeclared.
main( )
must be declared as public, since it must be called by codeoutside of its classe when the program is started.
static:
The keyword
static
allows
main( )
to be called without having to instantiatea particular instance of the class. This is necessary since
main ( )
is called by theJVM before any objects are made.
void:
The keyword
void
simply tells the compiler that
main ( )
doesn’t return avalue.
String args [ ]:
In
main ( ) ,
there is only one parameter, albeit a complicated one.
String args [ ]
declares a parameter named args, which is an array of instances of theclass String.
args
receives any command-line arguments present when the programis executed.
Math . sqrt ( ):
1
Leave a Comment