Size of Int in Java Is: A. 16 Bit B. 32 Bit C. 64 Bit D. Depends On Execution Environment Answer: Option B
Size of Int in Java Is: A. 16 Bit B. 32 Bit C. 64 Bit D. Depends On Execution Environment Answer: Option B
Size of Int in Java Is: A. 16 Bit B. 32 Bit C. 64 Bit D. Depends On Execution Environment Answer: Option B
Answer: Option B
A. 6 B. 7 C. 8 D. 9
Answer: Option C
Answer: Option A
Answer: Option B
5. The smallest integer type is ......... and its size is ......... bits.
Answer: Option B
Answer: Option A
7. Determine output:
class A{
public static void main(String args[]){
int x;
x = 10;
if(x == 10){
int y = 20;
System.out.print("x and y: "+ x + " " + y);
y = x*2;
}
y = 100;
System.out.print("x and y: " + x + " " + y);
}
}
A. 10 20 10 100 B. 10 20 10 20
C. 10 20 10 10 D. Error
Answer: Option D
A. Two type are compatible and size of destination type is shorter than source type.
B. Two type are compatible and size of destination type is equal of source type.
C. Two type are compatible and size of destination type is larger than source type.
Answer: Option C
Answer: Option C
class A{
public static void main(String args[]){
byte b;
int i = 258;
double d = 325.59;
b = (byte) i;
System.out.print(b);
i = (int) d;
System.out.print(i);
b = (byte) d;
System.out.print(b);
}
}
C. 2 325 69 D. Error
Answer: Option C
A. float B. double
Answer: Option B
A. Prints 2.5
Answer: Option A
int Integer = 34 ;
char String = 'S' ;
System.out.print( Integer ) ;
System.out.print( String ) ;
A. Does not compile as Integer and String are API class names.
B. Throws exception. C. 34 D. S E. 34 S
Answer: Option E
A. 20 B. 21 C. 22 D. Compilation Error
E. Throws Exception
Answer: Option C
Answer: Option C
A. 34 34 B. 65 34 C. 65 65 D. 34 65
Answer: Option B
Answer: Option B
A. 2 B. 0 C. 3
D. 2.5 E. 25
Answer: Option B
class A{
int k;
boolean istrue;
static int p;
public void printValue(){
System.out.print(k);
System.out.print(istrue);
System.out.print(p);
}
}
D. Compile error - static variable must be initialized before use. E. None of these
Answer: Option A
Answer: Option D
A. 87 B. 10 7
Answer: Option A
A. 14 21 B. 14 13
Answer: Option C
Answer: Option C
Answer: Option D
E. None of these
Answer: Option C
E. None of these
Answer: Option B
Answer: Option A
Answer: Option B
A. 0
Answer: Option A
A. The program has a compile error because the size of the array wasn't specified when
declaring the array.
B. The program has a runtime error because the array elements are not initialized.
D. The program has a runtime error because the array element x[0] is not defined.
Answer: Option C
A. 0 B. 1
C. 2 D. 3 E. 4
Answer: Option B
Answer: Option B
7. Determine output:
x = new int[2];
A. 1234 B. 0000
C. 12 D. 00 E. None of these
Answer: Option C
A. The code has compile errors because the variable arr cannot be changed once it is
assigned.
B. The code has runtime errors because the variable arr cannot be changed once it is
assigned.
C. The code can compile and run fine. The second line assigns a new array to arr.
D. The code has compile errors because we cannot assign a different size array to arr.
Answer: Option C
A. The program has a compile error because new int[2<sp< label=""> </sp<>
Answer: Option C
10. When you pass an array to a method, the method receives ________ .
Answer: Option C
11. What would be the result of attempting to compile and run the following code?
public class HelloWorld{
public static void main(String[] args){
double[] x = new double[]{1, 2, 3};
System.out.println("Value is " + x[1]);
}
}
A. The program has a compile error because the syntax new double[]{1, 2, 3} is wrong and it
should be replaced by {1, 2, 3}.
B. The program has a compile error because the syntax new double[]{1, 2, 3} is wrong and it
should be replaced by new double[3]{1, 2, 3};
C. The program has a compile error because the syntax new double[]{1, 2, 3} is wrong and it
should be replaced by new double[]{1.0, 2.0, 3.0};
Answer: Option D
Answer: Option D
Answer: Option D
14. What is the value of a[1] after the following code is executed?
A. 0 B. 1 C. 2
D. 3 E. 4
Answer: Option B
Answer: Option B
class LogicalCompare{
public static void main(String args[]){
String str1 = new String("OKAY");
String str2 = new String(str1);
System.out.println(str1 == str2);
}
}
A. true B. false C. 0
Answer: Option B
D. true true
Answer: Option D
4. Determine output:
A. true B. false C. 0
Answer: Option A
A. Throws an exception as string and int are not compatible for addition
B. hellow9 C. 9hellow
Answer: Option B
A. java.lang.String B. java.lang.Object
Answer: Option B
D. 1 E. -1
Answer: Option C
A. abc B. bc C. bcd
D. abcd E. None of these
Answer: Option B
A. true B. false C. 1
D. -1 E. 0
Answer: Option D
Answer: Option C
Answer: Option B
D. java.string
Answer: Option B
D. Compilation error
Answer: Option A
A. 4 B. 3 C. 2 D. None of this
Answer: Option B
A. 2 B. 7 C. 9 D. 11
E. None of this
Answer: Option D
Answer: Option A
A. true,true B. false,true
Answer: Option A
Answer: Option E
1. Determine output:
E. 6
Answer: Option E
2. In java, ............ can only test for equality, where as .......... can evaluate any type of the
Boolean expression.
D. continue, if
Answer: Option A
A. 06172838 B. 06172839
Answer: Option A
class Test{
public static void main(String args[]){
int x=7;
if(x==2); // Note the semicolon
System.out.println("NumberSeven");
System.out.println("NotSeven");
}
}
C. NotSeven D. Error
E. 7
Answer: Option A
5. Determine output:
public class Test{
public static void main(String args[]){
int i, j;
for(i=1, j=0;i<10;i++) j += i;
System.out.println(i);
}
}
A. 10 B. 11 C. 9 D. 20
E. None of these
Answer: Option A
D. Runtime Error
Answer: Option C
A. 1 B. 2 C. 3 D. 4 E. 0
Answer: Option B
char ch = 'a';
switch (ch){
case 'a':
case 'A': System.out.print(ch); break;
case 'b':
case 'B': System.out.print(ch); break;
case 'c':
case 'C': System.out.print(ch); break;
case 'd':
case 'D': System.out.print(ch);
}
A. abcd B. aa C. a D. ab E. abc
Answer: Option C
9. How many times will the following code print "Welcome to Examveda"?
int count = 0;
do {
System.out.println("Welcome to Examveda");
count++;
} while (count < 10);
A. 8 B. 9 C. 10 D. 11 E. 0
Answer: Option C
10. Choose the correct statement in context of the following program code.
A. The program has a compile error because the adjustment is missing in the for loop.
B. The program has a compile error because the control variable in the for loop cannot be of
the double type.
C. The program runs in an infinite loop because d<10 would always be true.
Answer: Option D
Answer: Option D
To view a Sol
A. 1231 B. 1232
Answer: Option C
A. 0 B. 1 C. 2 D. 3 E. 4
Answer: Option B
14. What will be the result of compiling and runnig the following code:
Answer: Option A
15. What all gets printed when the following program is compiled and run.
A. 0 B. 1 C. 2 D. 3 E. 12
Answer: Option E
16. What all gets printed when the following program is compiled and run?
A. 0 B. 1 C. 2
D. The program does not compile because of statement "i=++i;" E. None of these
Answer: Option C
A. 1 B. 2 C. -1 D. 0
E. None of these
Answer: Option D
1. int i = 10;
2. while(i++ <= 10){
3. i++;
4. }
5. System.out.print(i);
A. 10 B. 11 C. 12 D. 13
Answer: Option D
Prof. Swapnil S. Chaudhari
MCQ PPL
1. In Java variables, if first increment of the variable takes place and then the assignment
occurs. This operation is also called…………………………
A) pre-increment
B) post-increment
C) incrementation
D) pre incrementation
2. When the operators are having the same priority, they are evaluated from ……………..
…………. in the order they appear in the expression.
A) right to left
B) left to right
C) any of the order
D) depends on the compiler
3. In Java, …………. can only test for equality, whereas ………… can evaluate any type of
Boolean expression.
A) switch, if
B) if, switch
C) if, break
D) continue, if
4. The ………………….. looks only for a match between the value of the expression and
one of its case constants.
A) if
B) match
C) switch
D) None of the above
5. System.in.read() is being used, the program must specify the ……………… clause.
A) throws.java.out.IOException
B) throws.java.in.IOException
C) throws.java.io.IOException
D) throws.java.io.InException
6. By using ………………. you can force immediate termination of a loop, bypassing the
conditional expression and any remaining code in the body of the loop.
A) Break
B) Continue
C) Terminate
D) Loop Close
7. The out object is an object encapsulated inside the …………….. class and represents the
standard output device.
A) standard
B) local
C) global
D) system
8. The third type of comment is used by a tool called ……………… for automatic
generation of documentation.
A) Java commenting
B) Java generator
C) Java doc
D) Java loc
9. In the second type, the information written in java after // is ignored by the
…………………..
A) Interpreter
B) Compiler
C) Programmer
D) All of the above
10. The compiled Java program can run on any ………………… platform having Java
Virtual Machine (JVM) installed on it.
A) program
B) java
C) hardware
D) nonjava
Answers:
1. A) pre-increment
2. B) left to right
3. A) switch, if
4. C) switch
5. C) throws.java.io.IOException
6. A) Break
7. D) system
8. C) Java doc
9. B) Compiler
10.C) hardware
Answers:
1. D) Java, HTML
2. B) Throwable
3. A) must precede
4. B) java.lang
5. D) java.lang
6. A) i-false, ii-false
7. A) i-false, ii-false
8. C) The code will compile correctly and will print “In first main()” (without quotes) .. run
9. B) a-3, b-2, c-4, d-1
10.B) i-false, ii-false, iii-false, iv-false
1. The ……………… and ……………….. classes are abstract classes that support reading
and writing of byte streams.
A) reader, writer
B) inputstream, outputstream
C) objectinputstream, objectoutputstream
D) none
2. What is the error in the following code?
class Test
{
abstract void display( );
}
A) No error
B) Method display( ) should be declared as static
C) Test class should be declared as abstract
D) Test class should be declared as public
3. A package is a collection of
A) classes
B) interfaces
C) editing tools
D) classes and interfaces
4. Which of the following methods belong to the string class?
A) length( )
B) compare To ( )
C) equals ( )
D) All of them
5. What will be the output of the following code?
byte x=64, y;
y= (byte) (x<<2);
System.out.println(y);
A) 0
B) 1
C) 2
D) 64
6. If m and n are int type variables, what will be the result of the expression
m%n
when m=5 and n=2 ?
A) 0
B) 1
C) 2
D) None of the above
7. Which of the following control expressions are valid for an if statement?
A) An integer expression
B) A Boolean expression
C) Either A or B
D) Neither A nor B
8. The concept of multiple inheritances is implemented in Java by
A) extending two or more classes
B) extending one class and implementing one or more interfaces
C) implementing two or more interfaces
D) both B and C
9. Which of the following do not represent legal flow control statements?
A) break;
B) return;
C) exit();
D) continue outer;
10. Data input is
A) an abstract class defined in java.io
B) a class we can use to read primitive data types
C) an interface that defines methods to open files.
D) an interface that defines methods to read primitive data types.
Answers:
1. B) input stream, the output stream
2. C) Test class should be declared as abstract
3. D) classes and interfaces
4. D) All of them
5. A) 0
6. B) 1
7. B) A Boolean expression
8. D) both B and C
9. C) exit();
10.D) an interface that defines methods to read primitive data types.
1. Using which keyword we can access the value of the instance variables and class
variables of that class inside the method of that class itself.
A) super
B) final
C) this
D) either super or this
2. If a variable is declared final, it must include …………………. value.
A) integer
B) no
C) initial
D) float
3. State true or false.
i) Jpanel is a class included in awt package.
ii) Anonymous classes are mostly used for event handling.
iii) Names of anonymous classes must be unique
iv) JOptionPane is an inner class
A) i-false, ii-false, iii-true, iv-true
B) i-true, ii-false, iii-true, iv-false
C) i-false, ii-true, iii-false, iv-false
D) i-true, ii-false, iii-false, iv-true
4. In Java, a string is a ………….
A) primitive data type
B) abstract data type
C) combination of boolean
D) None of the above
5. Methods can be overloaded with a difference only in the type of the return value.
A) Not supported
B) False
C) True
D) None of the above
6. Each method in a java class must have a unique name.
A) Not necessary
B) True
C) False
D) None of the above
7. State true or false.
i) comparisons precede logical operations in java
ii) assignment operations succeed increment operations
iii) arithmetic operations succeed comparisons
iv) x precede +
A) i-true, ii-true, iii-false, iv-true
B) i-true, ii-false, iii-true, iv-false
C) i-false, ii-true, iii-false, iv-false
D) i-true, ii-false, iii-false, iv-true
8. It is an important feature of java that it always provides a default constructor to a class.
A) Not supported
B) False
C) True
D) None of the above
9. ………………….. is the key to ………………
A) Serialization, persistence
B) Persistence, inheritance
C) Inheritance, object
D) Persistence, serialization
10. State true or false.
i) The public can only be assigned to class
ii) Protected protects a statement
iii) Protected method is never accessible outside the package
iv) Friendly variable may be accessible outside the class
A) i-true, ii-true, iii-false, iv-true
B) i-true, ii-false, iii-true, iv-false
C) i-false, ii-true, iii-false, iv-false
D) i-true, ii-false, iii-false, iv-true
Answers:
1. C) this
2. C) initial
3. C) i-false, ii-true, iii-false, iv-false
4. B) abstract data type
5. B) False
6. A) Not necessary
7. A) i-true, ii-true, iii-false, iv-true
8. C) True
9. A) Serialization, persistence
10.C) i-false, ii-true, iii-false, iv-false
1. In java a ………………….. is a sequence of characters.
Java Objective Questions with Answers
Schema of the general architecture of a program running in a Java Virtual Machine
(Photo credit: Wikipedia)
A) string
B) arrayChar
C) groupChar
D) collection
2. Java programs perform I/O through ………..
A) I/O methods
B) I/O package
C) streams
D) compiler
3. What is the byte code in the context of Java?
A) The type of code generated by a Java compiler
B) The type of code generated by a Java Virtual Machine
C) It is another name for Java source file
D) It is the code written within the instance methods of a class
4. Which of the following statements about abstract methods/classes in Java is true?
A) An abstract class cannot be instantiated.
B) Constructors can be abstract.
C) A subclass of an abstract class must define the abstract methods.
D) Static methods may be declared abstract.
5. Which of the following statement is false?
A) The sleep() method should be enclosed in try ……… catch block
B) The yield() method should be enclosed in try ……… catch block.
C) A thread can be temporarily suspended from running by using the wait() method.
D) A suspended thread using suspend() method can be revived using the resume()
method.
6. The new operator dynamically allocates …………..for an object and returns a
reference to it.
A) classes
B) variables
C) memory
D) none of the above
7. Which of the following statements correctly describes an interface?
A) It’s a concrete class
B) It’s a superclass
C) It’s a type of abstract class
D) It’s a subclass
8. What is the priority of the Garbage collector thread of JDK?
A) Low Priority
B) Highest Priority
C) Medium Priority
D) Decided at run time
9. ……………. is a feature that allows one interface to be used for a general class of
actions.
A) Class
B) Inheritance
C) Polymorphism
D) Interface
10. The default package that is implicitly called in a java program is ………….
A) java. Lang
B) java.System
C) java. Window
D) java.Lang.System
Answers:
1. In java a ………………….. is a sequence of characters.
B) arrayChar
2. Java programs perform I/O through ………..
C) streams
3. What is the byte code in the context of Java?
A) The type of code generated by a Java compiler
4. Which of the following statements about abstract methods/classes in Java is true?
A) An abstract class cannot be instantiated.
5. Which of the following statement is false?
B) The yield() method should be enclosed in try ……… catch block.
6. The new operator dynamically allocates …………..for an object and returns a
reference to it.
C) memory
7. Which of the following statements correctly describes an interface?
C) It’s a type of abstract class
8. What is the priority of the Garbage collector thread of JDK?
A) Low Priority
9. ……………. is a feature that allows one interface to be used for a general class of
actions.
C) Polymorphism
10. The default package that is implicitly called in a java program is ………….
A) java. Lang
a) if
b) switch
c) if & switch
d) none of the mentioned
View Answer
Answer: b
Explanation: Switch statements checks for equality between the controlling variable and its constant
cases.
2. Which of these are selection statements in Java?
a) if()
b) for()
c) continue
d) break
View Answer
Answer:a
Explanation: Continue and break are jump statements, and for is an looping statement.
3. Which of the following loops will execute the body of loop even when condition controlling the loop is
initially false?
a) do‐while
b) while
c) for
d) none of the mentioned
View Answer
Answer: a
Explanation: None.
4. Which of these jump statements can skip processing remainder of code in its body for a particular
iteration?
a) break
b) return
c) exit
d) continue
View Answer
Answer: d
Explanation: None.
5. Which of these statement is incorrect?
a) switch statement is more efficient than a set of nested ifs
b) two case constants in the same switch can have identical values
c) switch statement can only test for equality, whereas if statement can evaluate any type of boolean
expression
d) it is possible to create a nested switch statements
View Answer
Answer: b
Explanation: No two case constants in the same switch can have identical values.
6. What is the output of this program?
class selection_statements
{
public static void main(String args[])
{
int var1 = 5;
int var2 = 6;
if ((var2 = 1) == var1)
System.out.print(var2);
else
System.out.print(++var2);
}
}
a) 1
b) 2
c) 3
d) 4
View Answer
Answer:b
Explanation: var2 is initialised to 1. The conditional statement returns false and the else part gets
executed.
output:
$ javac selection_statements.java
$ java selection_statements
2
7. What is the output of this program?
class comma_operator
{
public static void main(String args[])
{
int sum = 0;
for (int i = 0, j = 0; i < 5 & j < 5; ++i, j = i + 1)
sum += i;
System.out.println(sum);
}
}
a) 5
b) 6
c) 14
d) compilation error
View Answer
Answer: b
Explanation: Using comma operator , we can include more than one statement in the initialization and
iteration portion of the for loop. Therefore both ++i and j = i + 1 is executed i gets the value – 0,1,2,3,4 &
j gets the values ‐0,1,2,3,4,5.
output:
$ javac comma_operator.java
$ java comma_operator
68. What is the output of this program?
class jump_statments
{
public static void main(String args[])
{
int x = 2;
int y = 0;
for ( ; y < 10; ++y)
{
if (y % x == 0)
continue;
else if (y == 8)
break;
else
System.out.print(y + " ");
}
}
}
a) 1 3 5 7
b) 2 4 6 8
c) 1 3 5 7 9
d) 1 2 3 4 5 6 7 8 9
View Answer
Answer:c
Explanation: Whenever y is divisible by x remainder body of loop is skipped by continue statement,
therefore if condition y == 8 is never true as when y is 8, remainder body of loop is skipped by continue
statements of first if. Control comes to print statement only in cases when y is odd.
output:
$ javac jump_statments.java
$ java jump_statments
1 3 5 7 9
9. What is the output of this program?
class Output
{
public static void main(String args[])
{
final int a=10,b=20;
while(a<b)
{
System.out.println("Hello");
}
System.out.println("World");
}
}
a) Hello
b) run time error
c) Hello world
d) compile time error
View Answer
Answer: d
Explanation: Every final variable is compile time constant.
10. What is the output of this program?
class Output
{
public static void main(String args[])
{
int a = 5;
int b = 10;
first:
{
second:
{
third:
{
if (a == b >> 1)
break second;
}
System.out.println(a);
}
System.out.println(b);
}
}
}
a) 5 10
b) 10 5
c) 5
d) 10
Answer: d
Explanation: b >> 1 in if returns 5 which is equal to a i:e 5, therefore body of if is executed and block
second is exited. Control goes to end of the block second executing the last print statement, printing 10.
output:
$ javac Output.java
$ java Output
10
1. What would be the output of the following codesnippet if variable a=10?
if(a<=0)
{
if(a==0)
{
System.out.println("1 ");
}
else
{
System.out.println("2 ");
}
}
System.out.println("3 ");
a) 1 2
b) 2 3
c) 1 3
d) 3
View Answer
Answer: d
Explanation: Since the first if condition is not met, control would not go inside if statement and hence
only statement after the entire if block will be executed.
2. The while loop repeats a set of code while the condition is not met?
a) True
b) False
View Answer
Answer: b
Explanation: While loop repeats a set of code only until condition is met.
3. What is true about break?
a) Break stops the execution of entire program
b) Break halts the execution and forces the control out of the loop
c) Break forces the control out of the loop and starts the execution of next iteration.
d) Break halts the execution of the loop for certain time frame
View Answer
Answer: b
Explanation: Break halts the execution and forces the control out of the loop.
4. What is true about do statement?
a) do statement executes the code of a loop at least once
b) do statement does not get execute if condition is not matched in the first iteration
c) do statement checks the condition at the beginning of the loop
d) do statement executes the code more than once always
View Answer
Answer: a
Explanation: Do statement checks the condition at the end of the loop. Hence, code gets executed at
least once.
5. Which of the following is used with switch statement?
a) Continue
b) Exit
c) break
d) do
View Answer
Answer: c
Explanation: Break is used with switch statement to shift control out of switch.
6. What is the valid data type for variable “a” to print “Hello World”?
switch(a)
{
System.out.println("Hello World");
}
a) int and float
b) byte and short
c) char and long
d) byte and char
View Answer
Answer: d
Explanation: The switch condition would only meet if variable “a” is of type byte or char.
7. Which of the following is not a decision making statement?
a) if
b) if‐else
c) switch
d) do‐while
View Answer
Answer: d
Explanation: do‐while is an iteration statement. Others are decision making statements.
8. Which of the following is not a valid jump statement?
a) break
b) goto
c) continue
d) return
View Answer
Answer: b
Explanation: break, continue and return transfer control to another part of the program and returns
back to caller after execution. However, goto is marked as not used in Java.
9. From where break statement causes an exit?
a) Only from innermost loop
b) Terminates a program
c) Only from innermost switch
d) From innermost loops or switches
View Answer
Answer: d
Explanation: The break statement causes an exit from innermost loop or switch.
10. Which of the following is not a valid flow control statement?
a) exit()
b) break
c) continue
d) return
View Answer
Answer: a
Explanation: exit() is not a flow control statement in Java. exit() terminates the currently running JVM.
Which of these class is superclass of String and StringBuffer class?
A. java.util B. java.lang C. ArrayList D. None of the mentioned
Answer & Explanation
Answer: Option B
Explanation:
java.lang
2. Which of these operators can be used to concatenate two or more String objects?
A. + B. += C. & D. ||
Answer & Explanation
Answer: Option A
Explanation:
operator + is used to concatenate strings, Example String s = “i ” + “like ” + “java”; String s contains “I like
java”.
3. Which of these method of class String is used to obtain length of String object?
A. get() B. Sizeof() C. lengthof() D. length()
Answer & Explanation
Answer: Option D
Explanation:
Method length() of string class is used to get the length of the object which invoked method length().
4. Which of these method of class String is used to extract a single character from a String object?
A. CHARAT() B. charat() C. charAt() D. ChatAt()
Answer & Explanation
Answer: Option C
Explanation:
charAt()
5. Which of these constructors is used to create an empty String object?
A. String() B. String(void) C. String(0) D. None of the mentioned
Answer & Explanation
Answer: Option A
Explanation:
String()
7. Which of these method of class String is used to compare two String objects for their equality?
A. equals() B. Equals() C. isequal() D. Isequal()
Answer & Explanation
Answer: Option A
Explanation:
equals()
9. Which of these method of class String is used to check weather a given object starts with a particular
string literal?
A. startsWith() B. endsWith() C. Starts() D. ends()
Answer & Explanation
Answer: Option A
Explanation:
Method startsWith() of string class is used to check whether the String in question starts with a specified
string. It is specialized form of method regionMatches()
10. What is the value returned by unction compareTo() if the invoking string is less than the string
compared?
A. zero B. value less than zero C. value greater than zero D. None of the mentioned
Answer & Explanation
Answer: Option B
Explanation:
compareTo() function returns zero when both the strings are equal, it returns a value less than zero if
the invoking string is less than the other string being compared and value greater than zero when
invoking string is greater than the string compared to.
13.
What will s2 contain after following lines of code?
String s1 = “one”;
String s2 = s1.concat(“two”)
A. one B. two C. onetwo D. twoone
Answer & Explanation
Answer: Option C
Explanation:
Two strings can be concatenated by using concat() method.
14. Which of these method of class String is used to remove leading and trailing whitespaces?
A. startsWith() B. trim() C. Trim() D. doTrim()
Answer & Explanation
Answer: Option B
Explanation:
trim()
15. What is the value returned by function compareTo() if the invoking string is less than the string
compared?
A. zero B. value less than zero C. value greater than zero D. None of the mentioned
Answer & Explanation
Answer: Option B
Explanation:
compareTo() function returns zero when both the strings are equal, it returns a value less than zero if
the invoking string is less than the other string being compared and value greater than zero when
invoking string is greater than the string compared to.