You can do it as follows:
String section = "PRIMARY";
Optional.ofNullable(student)
.map( i -> (i.getStandard() > 5) ? "SECONDARY" : section )
.orElse(section);
solved How to simplify if statement using Optional.ofNullable() [closed]