Java Programming Multiple Choice Questions - Data Types
This section focuses on the "Data types" in Java programming. These Multiple Choice Questions (MCQ) should be practiced to improve the Java programming skills required for various interviews (campus interview, walk-in interview, company interview), placement, entrance exam and other competitive examinations.
1. Which of the following is smallest integer data type ?
View Answer
2. Which of the following is not a primitive data type ?
View Answer
3. Integer Data type does not include following primitive data type ____________.
View Answer
4. Which of the following data types comes under floating data types ?
View Answer
5. Character data type cannot store following value.
View Answer
6. Range of Byte Data Type is ____________.
View Answer
7. What is size of integer in Java Programming.
View Answer
8. Which of the following data type(s) can store 64 bit Value.
View Answer
9. Short data type has a minimum value of _____________.
View Answer
10. Default value of variable having boolean data type is ___________.
View Answer
11. What will be the output of the program?
class Main {
public static void main(String args[]) {
int t;
System.out.println(t);
}
}
View Answer
12. What will be the output of the program?
class Test {
public static void main(String[] args) {
for(int i = 0; 0; i++)
{
System.out.println(""Hello"");
break;
}
}
}
View Answer
13. What will be the output of the program?
class mainclass {
public static void main(String args[])
{
boolean var1 = true;
boolean var2 = false;
if (var1)
System.out.println(var1);
else
System.out.println(var2);
}
}
View Answer
14. Predict the output of the following program.
class LFC {
public static void main(String[] args)
{
Double object = new Double("2.4");
int a = object.intValue();
byte b = object.byteValue();
float d = object.floatValue();
double c = object.doubleValue();
System.out.println(a + b + c + d );
}
}
View Answer
15. Which of the following are legal lines of Java code?
1. int w = (int)888.8;
2. byte x = (byte)100L;
3. long y = (byte)100;
4. byte z = (byte)100L;
View Answer
16. What is the output of this program?
class average {
public static void main(String args[])
{
double num[] = {5.5, 10.1, 11, 12.8, 56.9, 2.5};
double result;
result = 0;
for (int i = 0; i<6; ++i)
result = result + num[i];
System.out.print(result/6);
}
}
View Answer
17. What is the output of this program?
class output {
public static void main(String args[])
{
double a, b,c;
a = 4.0/0;
b = 0/3.0;
c=0/0.0;
System.out.println(a);
System.out.println(b);
System.out.println(c);
}
}
View Answer
18. What will be the output of the program?
class increment {
public static void main(String args[])
{
int g = 4;
System.out.print(++g * 8);
}
}
View Answer
19. What will be the output of the program?
class area {
public static void main(String args[])
{
double r, pi, a;
r = 9.8;
pi = 3.14;
a = pi * r * r;
System.out.println(a);
}
}
View Answer
20. What will be the output of the program?
class increment {
public static void main(String args[])
{
int g = 6;
System.out.print(--g * 8);
}
}
View Answer
21. What is the range of short data type in Java?
View Answer
22. Which of the following are legal lines of Java code?
  1. int w = (int)888.8;
  2. byte x = (byte)100L;
  3. long y = (byte)100;
  4. byte z = (byte)100L;
View Answer
23. An expression involving byte, int, and literal numbers is promoted to which of these?
View Answer
24. Which of these literals can be contained in float data type variable?
View Answer
25. Which data type value is returned by all transcendental math functions?
View Answer
26. Which of these coding types is used for data type characters in Java?
View Answer
27. Which one is a valid declaration of a boolean?
View Answer
28. What is the output of this program?
class array_output {
public static void main(String args[])
{
char array_variable [] = new char[10];
for (int i = 0; i < 10; ++i) {
array_variable[i] = 'i';
System.out.print(array_variable[i] + """" );
i++;
}
}
}
View Answer
29. Which of these is long data type literal?
View Answer
30. Which of these can be returned by the operator &?
View Answer
Also check :
- Java Interview Questions
- AssignmentCore can do your Java homework if you need expert help with your Java projects or assignments.
Discussion