🚀 Join 1,200+ candidates currently preparing with PrimerPrep
Java Programming
Accenture Technical PrimermediumJava Programming3. Class And Objects, Date Api

Accenture Java Programming Practice Question

Consider the below code snippet and determine the output. class Student { private int studentId; private float average; } class Test { public static void main(String a[]) { Student s=new Student(); s.studentId=123; System.out.println(s.studentId); } }

Answer options

A
Compile-time error
B
Prints 123
C
0
D
Runs with no output

Correct answer: Compile-time error

Explanation

Quick AnswerThe correct answer is Compile-time error because it directly addresses the core logic of Java Programming.

studentId is private; accessing it from outside the class causes a compile-time error.

Related Accenture Java Programming questions

Practice more Accenture Java Programming questions

PrimerPrep has 1400+ practice questions, 2026 simulations and coding hands-on — all free.

Watch Walkthroughs!