| 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 5 students
Java Nested Method Definition
< Prev
Next >

What error prevents this code from compiling?

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

The innerMethod is missing a return type.

C

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

D

There is a missing semicolon after the innerMethod definition.

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

Question Leaderboard

Rank
User
Correct Count
Attempt Count
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
No comments yet. Be the first to comment!

AI Tutor

How can I help?

APFIVE © 2020.
Email: [email protected]|Privacy Policy