What is the result?

Given the code fragment:

What is the result?
A. true true
B. true false
C. false false
D. false true

Download Printable PDF. VALID exam to help you PASS.

2 thoughts on “What is the result?

  1. C
    public static void main(String[] args) {
    String s =” “;
    System.out.println(s.equals(“”)+” “+s.isEmpty());
    false false

  2. Answer C:

    the str.trim() got ignored (i.e. has not been saved to any variable. So str remains as it is.
    An empty space in a string (i.e. ” “) is actually filled with a blank character, meaning that this String is not empty.


Leave a Reply

Your email address will not be published. Required fields are marked *

The reCAPTCHA verification period has expired. Please reload the page.