DEV Community

Cover image for core java-Basics
Sahithi Puppala
Sahithi Puppala

Posted on • Updated on

core java-Basics

Day-2

Let's Continue..........................................

in java we are having '3' basic Programming elements we know

1) Class [Class is use above 90% in java]
2) Interface [Interface is use in 8 to 10% ]==>when we use -"if we want to achieve abstraction. "
3) Enum [we use less than 2%]==>When we use-"if our project is having universal constants"

LET'S GOTO THE IMPORTANT TOPIC IN JAVA ---JAVA METHOD

Q)WHAT IS A JAVA METHOD?
A:It is a place where we will be writing the 'Business Logic'

i think you all are one doubt!!!
==>what is BUSINESS LOGIC-"Business logic is any kind of code."

Lets go learn Syntax of a java Method ?

()
{
----------;
----------; //Method body/Functionality/implementation
----------;
}

Note :()-Parenthesis

We know what is Access Modifiers let's learn 'Return Type'

Return Type:

 We are having '4' options for returning a value from a method
Enter fullscreen mode Exit fullscreen mode

1)void
2)We can use all the '8' Primitive datatypes.[int ,byte ,short ,long ,float ,double ,char ,boolean]
3)Classes
4)Interfaces

in java mostly used in void return type why because

void -No Need to Return anything

Example:
Public void meth()
{
-------;
}

==>we can write any number of methods inside a class.
==>A java Method will be executed "ONLY" whenever we are calling it.
==> We need to call a method with the help of its "Respective" Class Object.

Note:
1) Every java Program execution start from main() and ends with main()
2)main() is like a entry point our program.
3)Without writing main() in our Program we will not be able to run our code.

We will discuss what is object!!!
waiting for Day-3 ----------------------------------------------------

Top comments (0)