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
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
No comments:
Post a Comment