Java Programming Exam Questions And
Answers 100% Verified And Updated.
________ represents an entity in the real world that can be distinctly identified. - Answer✔An
Object
________ is a construct that defines objects of the same type. - Answer✔A class
An object is an instance of a ________ - Answer✔class
The keyword ________ is required to declare a class. - Answer✔class
________ is invoked to create an object. - Answer✔A constructor
The default value for data field of a boolean type, numeric type, object type is ________,
respectively - Answer✔false, 0, null
public class Test{
int x;
public Test(String t){
System.out.println("Test");
}
public static void main(String[] args){
Test test = new Test();
System.out.println(test.x);
}
} - Answer✔The program has a compile error because Test does not have a default constructor
Java assigns a default value to a date member of a class if the data is not initialized -
Answer✔True
1|Page
, ©FYNDLAY 2024/2025 ALL RIGHTS RESERVED.
The default constructor has no arguments - Answer✔True
You can access a class variable using a syntax like objectName.classVariable or
ClassName.classVariable - Answer✔True
Which one of the following statements are correct - Answer✔char[][] charArray = {{'a','b'},
{'c','d'}}
Assume double[][] x = new double[4][5], what are x.length and x[2].length? - Answer✔4 and 5
What is the index variable for the element at the first row and first column in array a? -
Answer✔a[0][0]
___is the physical aspect of the computer that can be seen - Answer✔hardware
How many Elements are array matrix (int[][] matrix = new int[5][5])? - Answer✔25
Assume int[][][] x = new char [2][5][3], how many elements are there in the array? - Answer✔30
What is the printout of the following program?
program public class Test{
public static void main(String[] args){
int[][] values = {{3, 4, 5, 2}, {33, 6, 1, 2}};
for (int row = 0; row < values.length; row++){
java.util.Arrays.sort(Values[row].length; column++);
System.out.print(values[row][column]+" ");
System.out.println();
}
}
} - Answer✔The program prints two rows 1 3 4 5 followed by 1 2 6 33
What is the output for the following code?
public class test{
public static void main(String[] args){
int[][] matrix =
{{1, 2, 3, 4},
{4, 5, 6, 7,},
2|Page