github

Made bySaurav Hathi

MCQ Test Java: Strings and Dates

Q1:

Which of these is incorrect string literal in java?

Tags:
Section:
Core Programming
Options:
Q2:

String in Java is a?

Tags:
Section:
Core Programming
Options:
Q3:

Which of these methods of String class is used to obtain character at specified index in java?

Tags:
Section:
Core Programming
Options:
Q4:

Which of these methods of String class can be used to compare two strings based on their content in java?

Tags:
Section:
Core Programming
Options:
Q5:

Which of the following statements is incorrect about strings in java?

Tags:
Section:
Core Programming
Options:
Q6:

Which of these methods of class String is used to obtain length of a String object in java?

Tags:
Section:
Core Programming
Options:
Q7:

Which of these constructors is used to create an empty String object in java?

Tags:
Section:
Core Programming
Options:
Q8:

Which of these is an incorrect statement about strings in java?

Tags:
Section:
Core Programming
Options:
Q9:

In java, which of these methods is an alternative to getChars() that stores the characters in an array of bytes?

Tags:
Section:
Core Programming
Options:
Q10:

Which of these methods is used to compare a specific region inside a string with another specific region in another string in java?

Tags:
Section:
Core Programming
Options:
Q11:

In the below java code, which code fragment should be inserted at line 3 so that the output will be: “123abc 123abc”?

1 StringBuilder sb1 = new StringBuilder("123");

2 String s1 = "123";

3  // insert code here

4 System.out.println(sb1 + " " + s1);

Tags:
Section:
Core Programming
Options:
Q12:

Which of these method of class String is used to extract a substring from a String object in java?

Tags:
Section:
Core Programming
Options:
Q13:

Which of these method of class String is used to remove leading and trailing whitespaces in java?

Tags:
Section:
Core Programming
Options:
Q14:

What is the output of this java program?

class Output

{

    public static void main(String args[])

    {

        long start, end;  

        start = System.currentTimeMillis();

        for (int i = 0; i < 10000000; i++);

        end = System.currentTimeMillis();

        System.out.print(end - start);

    }

}

Tags:
Section:
Core Programming
Options:
Q15:

How to format date from one form to another in java?

Tags:
Section:
Core Programming
Options:
Q16:

How to identify if a timezone is eligible for DayLight Saving in java?

Tags:
Section:
Core Programming
Options:
Q17:

How to get difference between two dates in java?

Tags:
Section:
Core Programming
Options:
Q18:

In java, which of these classes is used to create an object whose character sequence is mutable?

Tags:
Section:
Core Programming
Options:
Q19:

What is the string contained in s after following java code is executed?

StringBuffer s = new StringBuffer(“Hello”);

s.deleteCharAt(0);

Tags:
Section:
Core Programming
Options:
Q20:

What is the output of this java program?

class output

{

public static void main(String args[])

{

StringBuffer c = new StringBuffer("Hello");

c.delete(0,2);

System.out.println(c);

}

}

Tags:
Section:
Core Programming
Options: