Ask Question
13 October, 02:21

What is the output of the following code snippet? public static int assignPriority (int priority) { return priority + 2; } public static void main (String[] args) { int priority = assignPriority (3); System. out. println ("Priority: " + priority); }

+2
Answers (1)
  1. 13 October, 04:18
    0
    The output of the given code is "5".

    Explanation:

    In the given code a method "assignPriority" is declared, which accepts an integer parameter "Priority", and inside the method, it will return an integer variable "Priority" value with add a number "2".

    This method uses int as a return type, which means, it will return an integer value. In the main function, an integer variable "Priority" is declared, that holds function return value, and in calling time it will accept a value that is "3", at the last print method prints its value.
Know the Answer?
Not Sure About the Answer?
Find an answer to your question ✅ “What is the output of the following code snippet? public static int assignPriority (int priority) { return priority + 2; } public static ...” in 📘 Computers and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers