Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

1)What will be the output of this program ? class Test { public static void main

ID: 3540755 • Letter: 1

Question

1)What will be the output of this program ?

class Test
{
    public static void main(String args[])
    {
        String s1="Include";
        String s2="Help";
        String s3;
        s3=s1.concat(s2.toUpperCase());
        System.out.println(s1+","+s2+","+s3);

    }
}
a.Include,Help,IncludeHELP
b.Include,Help,IncludeHelp
c.Include,Help,IncludeHelpIncludeHelp
d.None of these


2)How can we add two strings without using concat method?

class Test
{
    public static void main(String args[])
    {
        String s1="Include";
        String s2="Help";
        String s3;
        s3=________;
        System.out.println(s3);

    }
}
a.s1+s2
b.s1&s2
c.s1&&s2
d."s1"&"s2"


3)What will be the output of this program ?

class Test
{
    public static void main(String args[])
    {
        String strVar=new String("Hello");
        System.out.println(strVar.substring(2,3));

    }
}
a.llo
b.l
c.ell
d.el

4)What will be the output of this program ?

class Test
{
    public static void main(String args[])
    {
        boolean ans=false;
        if(ans=true)
            System.out.print("Done");
        else
            System.out.print("Fail");
    }
}
a.Done
b.Fail
c.ERROR
d.DoneFail


5)What will be the output of this program ?

class Test
{
    public static void main(String args[])
    {
        byte a,b;
        a=10; b=20;
        b=assign(a);
        System.out.println(a +","+ b);

         
    }
    public static byte assign(byte a)
    {
        a+=100;
        return a;
    }
     
}
110,110
10,110
10,10
None of these

Explanation / Answer

1)Include,Help,IncludeHELP


2)s1+s2


3)l

substring(index1,index2); returns the string from index1 to index 2, in this program substring will return string between index 2 to 3, means only l will return.


4)done

in condition ans=true,the value of ans becomes true hence condition is true.


5)10,110

here variable a in main and a in assign are different, only value of a (10) will pass into function assign, value of a will remain same, answer will 10,110