FCPS Review Questions.docx - Name:Siddant FCPS Exam Review...

This preview shows page 1 - 3 out of 6 pages.

Name:Siddant FCPS Exam Review 1. a. Write a Java method that would return a person’s first, middle and last names together as one String with spaces between each. public static String name (String first, String middle, String last) { Return first + “ ” + middle + “ ” + last } b. Give an example of how you could call this method in your “main” method on your name, printing the result to the screen. (You can just call the method with literal values, no need to capture user input) public static void main(String[] args) { String nameFull = name(first, middle, last) Sysout(nameFull) } 2. a. (2) Write a method that takes an integer argument/input and returns a String stating whether the number is even or odd. public static String evenOrOdd(int x) { Int input = sc.nextInt(); if(input%2 = 1) Return “odd” Else Return output }
Image of page 1

Subscribe to view the full document.

b. (1) Give an example of how you could call this method in your “main” method on 111, printing the result to the screen. (You can just call the method with literal values, no need to capture user input)
Image of page 2
Image of page 3
You've reached the end of this preview.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern