Java Programming
primer-original-v2mediumJava Programming03 Class And Objects, Date Apiprimer-original-v2

Java Programming Practice Question

Observe the code below. public class Student { int studentId; String name; char grade; public Student(int studentId, String name, float mark) { this.studentId = studentId; this.name=name; calculateGrade(mark); } public void calculateGrade(float mark){ if(mark>90) grade='A'; else grade='B'; } } For the code Student s = new Student(1,"Peter",95); What will be the output?

Answer options

A
No output (no print statement in the code shown)
B
Compile-time error
C
Runtime error
D
Grade A assigned

Correct answer: No output (no print statement in the code shown)

Explanation

Quick AnswerThe correct answer is No output (no print statement in the code shown) because it directly addresses the core logic of Java Programming.

This question has been retained as-is due to its unique context.

Related Java Programming questions

Practice more Java Programming questions

PrimerPrep has independently reviewed practice questions and coding exercises — all free.