How to find even or odd using call by value

+1 vote
How to find odd or even using call by value in Java?
Nov 23, 2018 in Java by Nitesh
• 3,080 points
1,466 views

1 answer to this question.

0 votes

Call by value is, when a primitive data type is sent as an argument to the function it returns the data sent by function.

import java.util.Scanner;
public class Even 
{
    static void checknumber (int n)
    {
        if(n%2==0)
            System.out.println("Even");
        else
            System.out.println("Odd");
    }
    public static void main(String[] args) 
    {
        System.out.println("Enter a number");
        Scanner in = new Scanner(System.in);
        int n=in.nextInt();
        Even.checknumber(n);
    }

}

This way you can implement the program.

answered Nov 23, 2018 by Namitha

Related Questions In Java

0 votes
1 answer

How to resolve the error: could not find or load main class?

If you are getting error: could not ...READ MORE

answered May 28, 2018 in Java by Parth
• 4,640 points
11,396 views
0 votes
2 answers

How to find out a single character appears in String or not in Java?

You can use string.indexOf('s'). If the 's' is present in string, ...READ MORE

answered Aug 7, 2018 in Java by Sushmita
• 6,920 points
5,671 views
0 votes
1 answer

How to call a method after a delay in Android using Java?

final Handler handler = new Handler(); handler.postDelayed(new Runnable() ...READ MORE

answered Jun 11, 2018 in Java by Akrati
• 3,190 points
5,326 views
0 votes
0 answers

How to remove item from array by value?

Is it possible to delete an item ...READ MORE

Nov 17, 2022 in Java by Nicholas
• 7,760 points
326 views
+1 vote
1 answer

Are arrays equivalent to objects in Java ?

Yes; the Java Language Specification writes: In the Java ...READ MORE

answered May 10, 2018 in Java by Rishabh
• 3,620 points
1,296 views
+1 vote
1 answer

Remove objects from an array in Java?

We can use external libraries: org.apache.commons.lang.ArrayUtils.remove(java.lang.Object[] array, int ...READ MORE

answered Jun 26, 2018 in Java by scarlett
• 1,290 points
1,165 views
+1 vote
1 answer

Performance difference of if/else vs switch statement in Java

The thing you are worried about is ...READ MORE

answered Jul 26, 2018 in Java by geek.erkami
• 2,680 points
3,719 views
+1 vote
3 answers

What is the syntax to declare and initialize an array in java?

You can use this method: String[] strs = ...READ MORE

answered Jul 25, 2018 in Java by samarth295
• 2,220 points
3,534 views
0 votes
2 answers

How to move or copy a file in Java

The new JAVA Specification Request 203 -NIO will ...READ MORE

answered Aug 20, 2019 in Java by Sirajul
• 59,230 points
934 views
0 votes
1 answer

How to call a method from Constructor?

Have a glance at below steps: You create ...READ MORE

answered Nov 13, 2018 in Java by Frankie
• 9,830 points
7,036 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP