What is the result of compiling and running the following code? class Tester { public static void main(String args[]

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899603
Joined: Mon Aug 02, 2021 8:13 am

What is the result of compiling and running the following code? class Tester { public static void main(String args[]

Post by answerhappygod »

What is the result of compiling and running the followingcode?class Tester { public static void main(String args[]) { String s1 = null; String s2 = null; if(s1 == s2) System.out.print("A"); if(s1.equals(s2)) System.out.print("B"); }}
"A" will be printed
No output is produced
"B" will be printed
"A" will be printed followed by a NullPointerExceptionthrown
"AB" will be printed
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply