Quiz J0-1 | CS 2113 Software Engineering - Spring 2021

Quiz J0-1

Submit your answers via this Google Form

Question 1

What is the output of the below program?

    public static void main(String args[]){
        String str = "Java is my favorite language";
        str += '!';
        System.out.println(str+" and python is my second");
    }

Question 2

What is the output of the below program?

    public static void main(final String args[]){
        String choice = new String("A");
        if (choice == "A"){
            System.out.println("Correct");
        }else{
            System.out.println("Wrong");
        }
    }

Question 3

Does the below program change the season?

    static void change_season(String str){
        str = "Spring";
    }

    public static void main(final String args[]){
        String season = "Winter";
        change_season(season);
        System.out.println("The current season is: " + season);
    }

Question 4

What is the output of the below program?

    static boolean check_one(String str){
        if(str.equals(" 2 3 4 5"))
            return true;
        return false;
    }

    static boolean check_two(String str) {
        if (str.charAt(9) == '\0')
            return true;
        return false;
    }
    public static void main(final String args[]){
        String numbers = "1 2 3 4 5";
        System.out.println(check_one(++numbers) || check_two(numbers));
    }

Question 5

What is the output of the below program?

    static boolean check_one(String str){
        if(str.equals(" 2 3 4 5"))
            return true;
        return false;
    }

    static boolean check_two(String str) {
        if (str.charAt(9) == '\0')
            return true;
        return false;
    }
    public static void main(final String args[]){
        String numbers = "1 2 3 4 5";
        System.out.println(check_one(numbers) || check_two(numbers));
    }