13
answers
0
watching
567
views
2 Oct 2018
(b) Consider the following classes: public class House - ي شما هر چند = = private String rooms; public House() String rooms - new String [31; rooms (0) - "living room"; rooms [1] - "kitchen"; rooms (2) - "bedroom"; = public void print RoomList () for (int i-0; i < rooms.length; i++) { System.out.println (rooms[1]); = ہم نوا شهيد - public class Block يا نو public static void main(String[args) له House myblouse - new House(); myHouse.print RoomList(); د ه د The program compiles, but when you run the program, you get the following exception: Exception in thread "main" java.lang.NullPointerException at House.print RoomList (House.java:12) at Block.main (Block.java:6) The point of the method printRoomList is to print all the Strings in the house to the screen. Why does it give the error and write the code to fix the error while successfully printing all the rooms to the screen?
(b) Consider the following classes: public class House - ي شما هر چند = = private String rooms; public House() String rooms - new String [31; rooms (0) - "living room"; rooms [1] - "kitchen"; rooms (2) - "bedroom"; = public void print RoomList () for (int i-0; i < rooms.length; i++) { System.out.println (rooms[1]); = ہم نوا شهيد - public class Block يا نو public static void main(String[args) له House myblouse - new House(); myHouse.print RoomList(); د ه د The program compiles, but when you run the program, you get the following exception: Exception in thread "main" java.lang.NullPointerException at House.print RoomList (House.java:12) at Block.main (Block.java:6) The point of the method printRoomList is to print all the Strings in the house to the screen. Why does it give the error and write the code to fix the error while successfully printing all the rooms to the screen?
29 Jun 2023
Already have an account? Log in
marcusnicole284Lv10
16 Jun 2023
Already have an account? Log in
celluarsolLv10
7 Mar 2023
Already have an account? Log in
11 Feb 2023
Already have an account? Log in
papayaprofessorLv10
5 Sep 2022
Already have an account? Log in
Irving HeathcoteLv2
5 Oct 2018
Already have an account? Log in