public int getCountOfStudents(List line){if(line != null) {if(line.listOfStudents() != null) { return line.listOfStudents().size();}}throw new NullPointerException("List is empty");} Correct Answer Option (ii) "/> public int getCountOfStudents(List line){if(line != null) {if(line.listOfStudents() != null) { return line.listOfStudents().size();}}throw new NullPointerException("List is empty");}"> public int getCountOfStudents(List line){if(line != null) {if(line.listOfStudents() != null) { return line.listOfStudents().size();}}throw new NullPointerException("List is empty");} "/> public int getCountOfStudents(List line){if(line != null) {if(line.listOfStudents() != null) { return line.listOfStudents().size();}}throw new NullPointerException("List is empty");} Correct Answer Option (ii) "/> public int getCountOfStudents(List line){if(line != null) {if(line.listOfStudents() != null) { return line.listOfStudents().size();}}throw new NullPointerException("List is empty");}">

What one of the following is best practice to handle Null Pointer exception?
i) int noOfStudents = line.listStudents().count;
ii) int noOfStudents = getCountOfStudents(line);

public int getCountOfStudents(List line){if(line != null) {if(line.listOfStudents() != null) { return line.listOfStudents().size();}}throw new NullPointerException("List is empty");}
Correct Answer Option (ii)

শেয়ার করুন বন্ধুর সাথে

বিসিএস, ব্যাংক, প্রাইমারি সহ সরকারি বেসরকারি চাকুরীর পরীক্ষার প্রস্তুতির জন্য ডাউনলোড করুন Bissoy অ্যাপ

Related MCQ's

The correct statement for a function that takes pointer to a float, a pointer to a pointer to a char and returns a pointer to a pointer to a integer is ____________

The correct statement for a function that takes pointer to a float, a pointer to a pointer to a char and returns a pointer to a pointer to a integer is