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,497 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,431 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,717 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,337 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
341 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,326 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,185 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,740 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,578 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
964 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,079 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