Objective type
questions of string literals and answers in java programming
(1)
public class Literal {
public static void main(String[] args) {
String a="c:\\tc\\bin";
System.out.println(a);
}
}
What will output when you compile and run the above code?
(a) c:\\tc\\bin
(b) c:\tc\bin
(c) c: c\bin
(d) Compiler error
Answer: (b)
(2)
public class Literal {
public static void main(String[] args) {
String str="my id is :\12 and your";
System.out.println(str);
}
}
What will output when you compile and run the above code?
(a) my id is :\12 and your
(b) my id is :10 and your
(c) my id is :
and your
(d) Compiler error
Answer: (c)
(3)
public class Literal {
public static void main(String[] args) {
String str="I know java\networking";
System.out.println(str);
}
}
What will output when you compile and run the above code?
(a) I know java\networking
(b) I know java
etworking
(c) null
(d) Compiler error
Answer: (b)
(4)
public class Literal {
public static void main(String[] args) {
String str="I know java\c++";
System.out.println(str);
}
}
What will output when you compile and run the above code?
(a)I know java\c++
(b)I know java\c++\0
(c)“I know java\c++”
(d) Compiler error
Answer: (d)
(5)What will be output of following program?
class StringLiteral
{
public static void main(String[] args)
{
String str="india\0 usa ";
System.out.println(str);
}
}
What will output when you compile and run the above code?
(a)India\0 usa
(b)india usa
(c)india
(d)Compiler error
Answer: (c)
Java questions of data types and answer
Java questions on if else statements
Java questions on switch case and answers
Java questions on looping and answers
Java questions on characters
Java questions on strings and answers
Java questions on variables and answers
Java questions on automatic type promotions
Java questions on bit wise operator
Java questions on operators and answers
Java questions on static keyword and answers
Java questions on super keyword and answers
Java questions on abstract class an answers
Java questions on interface and answers
Java questions on enum data type and answers
Java questions on break and continue keyword
Java questions of primitive data types
Java questions on conditional operators
Java questions on two dimensional array and answers
Java questions of data types and answer
Java questions on if else statements
Java questions on switch case and answers
Java questions on looping and answers
Java questions on characters
Java questions on strings and answers
Java questions on variables and answers
Java questions on automatic type promotions
Java questions on bit wise operator
Java questions on operators and answers
Java questions on static keyword and answers
Java questions on super keyword and answers
Java questions on abstract class an answers
Java questions on interface and answers
Java questions on enum data type and answers
Java questions on break and continue keyword
Java questions of primitive data types
Java questions on conditional operators
Java questions on two dimensional array and answers
1 comment:
Nice information. Thanks for sharing such an useful and helpful post.
Java course in Pune
Post a Comment