Java data type questions and answers with govind
Java objective type data type questions and answers
(1)What will be the output of following java program?
class Datatype{
public static void main(String[] args){
byte num=(byte)130;
System.out.print(num);
}
}
Output: -126
(2)What will be the output of following java program?
class Datatype{
public static void main(String[] args){
byte num=130;
System.out.print(num);
}
}
Output: Compiler error
(3)What will be the output of following java program?
class Datatype{
public static void main(String[] args){
byte number=0101;
System.out.print(number);
}
}
Output: 65
(4)What will be the output of following java program?
class Datatype{
public static void main(String[] args){
short num=0x8fff;
System.out.print(num);
}
}
Output: compiler error
(5)What will be the output of following java program?
class Datatype{
public static void main(String[] args){
char num=65;
System.out.println(num);
}
}
Output: A
(6)What will be the output of following java program?
class Datatype{
public static void main(String[] args){
String str="india\0 usa";
System.out.println(str);
}
}
Output: India
(7)What will be the output of following java program?
class Datatype{
public static void main(String[] args){
String str="india\11usa";
System.out.println(str);
}
}
Output: india usa
(8)What will be the output of following java program?
class Datatype{
public static void main(String[] args){
String str="india\12usa";
System.out.println(str);
}
}
Output:
india
usa
(9)What will be the output of following java program?
class Datatype{
public static void main(String[] args){
String str="india\rome";
System.out.print(str);
}
}
Output:
india
ome
(10)What will be the output of following java program?
class Datatype{
public static void main(String[] args){
String str="japan\taskand";
System.out.print(str);
}
}
Output: japan askand
(11)What will be the output of following java program?
class Datatype{
public static void main(String[] args){
String str="local\national";
System.out.print(str);
}
}
Output:
local
ational
No comments:
Post a Comment