51. What is the output for the below code?
public class Test{
int _$;
int $7;
int do;
public static void main(String argv[]){
Test test = new Test();
test.$7=7;
test.do=9;
System.out.println(test.$7);
System.out.println(test.do);
System.out.println(test._$);
}
}
public class Test{
int _$;
int $7;
int do;
public static void main(String argv[]){
Test test = new Test();
test.$7=7;
test.do=9;
System.out.println(test.$7);
System.out.println(test.do);
System.out.println(test._$);
}
}
52. What is the output for the below code?
public class Test{
public static void main(String[] args){
int i = 010;
int j = 07;
System.out.println(i);
System.out.println(j);
}
}
public class Test{
public static void main(String[] args){
int i = 010;
int j = 07;
System.out.println(i);
System.out.println(j);
}
}
53. What is the output for the below code?
public class Test{
public static void main(String[] args){
byte b = 6;
b+=8;
System.out.println(b);
b = b+7;
System.out.println(b);
}
}
public class Test{
public static void main(String[] args){
byte b = 6;
b+=8;
System.out.println(b);
b = b+7;
System.out.println(b);
}
}
54. What will be the output for the below code?
public class Test{
public static void main(String[] args){
byte i = 128;
System.out.println(i);
}
}
public class Test{
public static void main(String[] args){
byte i = 128;
System.out.println(i);
}
}
55. What will be the output for the below code?
public class Test{
int i=8;
int j=9;
public static void main(String[] args){
add();
}
public static void add(){
int k = i+j;
System.out.println(k);
}
}
public class Test{
int i=8;
int j=9;
public static void main(String[] args){
add();
}
public static void add(){
int k = i+j;
System.out.println(k);
}
}
56. What will be output of following program?
public class Test{
public static void main(String[] args){
byte b=127;
b++;
b++;
System.out.println(b);
}
}
public class Test{
public static void main(String[] args){
byte b=127;
b++;
b++;
System.out.println(b);
}
}
57. Determine output:
public class Test{
int a = 10;
public void method(int a){
a += 1;
System.out.println(++a);
}
public static void main(String args[]){
Test t = new Test();
t.method(3);
}
}
public class Test{
int a = 10;
public void method(int a){
a += 1;
System.out.println(++a);
}
public static void main(String args[]){
Test t = new Test();
t.method(3);
}
}
58. Which class does all the Enums extend?
59. Which of the following is the advantage of BigDecimal over double?
60. What will be the output of the following Java code snippet?
double a = 0.02;
double b = 0.03;
double c = b - a;
System.out.println(c);
BigDecimal _a = new BigDecimal("0.02");
BigDecimal _b = new BigDecimal("0.03");
BigDecimal _c = b.subtract(_a);
System.out.println(_c);
double a = 0.02;
double b = 0.03;
double c = b - a;
System.out.println(c);
BigDecimal _a = new BigDecimal("0.02");
BigDecimal _b = new BigDecimal("0.03");
BigDecimal _c = b.subtract(_a);
System.out.println(_c);
Read More Section(Data Types and Variables)
Each Section contains maximum 100 MCQs question on Data Types and Variables. To get more questions visit other sections.