Are you taking CLEP classes? Try clep.ai
| preferred AP College board partner for AP classes
AP Computer Science A/Unit 5: Writing Classes
Start Practice TestPractice Test
About Exam
easy Solved by 4 students

Java Nested Method Definition

Mark
< Prev
Next >

Which of the following best explains why the provided code will not compile?

public class Outer {
    public static void main(String[] args) {
        System.out.println("Hello");
        void innerMethod() {
            System.out.println("Inner");
        }
    }
}
A

The System.out.println statement in main is incorrect.

B

There is a missing semicolon after the innerMethod definition.

C

The innerMethod is missing a return type.

D

Defining a method inside another method is not allowed in Java.

Hint
Did You Know?
Explain Why
Explain All Answers
Check Answer
Show Correct Answer
Report Question

Question Leaderboard

Rank
User
Correct Count
Attempt Count
Total Time
Score
#1kaisuki11 0m 00s 100
#2gtsak3111 2m 57s -77
#3bommasam00011 4m 22s -162
#4y.seong202712 5m 44s -254
Items per page:
10
1 – 4 of 4

AI Tutor

How can I help?

APFIVE © 2020.
Email: apfive@apfive.org|Privacy Policy|