LPU Java Unit 2 Lecture 15 MCQ String Builder Class RB | LPUCOLAB

LPU Java Unit 2 Lecture 15 MCQ String Builder Class RB | LPUCOLAB

LPU_Java_Unit 2_Lecture 15_MCQ_String Builder Class_RB

1. What will be the output of the following code?

public class Main{  
    public static void main(String args[]){  
        StringBuilder sb=new StringBuilder("Stock");  
        sb.replace(1,3,"Market");  
        System.out.print(sb);
    }  
}

Answer:
SMarketck


2. What will be the output of the following code?

public class Main{  
    public static void main(String args[]){  
        StringBuilder obj=new StringBuilder("Programming");  
        obj.delete(1,3);  
        System.out.print(obj);
    }  
}

Answer:
Pgramming


3. What will new StringBuilder("Hi").length() return?

Answer:
2