Premium

Oracle Java Programming Certification Questions and Answers (Dumps and Practice Questions)



Question : Which three statements are benefits of encapsulation?
A. Allows a class implementation to change without changing t he clients
B. Protects confidential data from leaking out of the objects
C. Prevents code from causing exceptions
D. Enables the class implementation to protect its invariants
E. Permits classes to be combined into the same package
F. Enables multiple instances of the same class to be created safely
 : Which three statements are benefits of encapsulation?
1. A,B,C
2. B,C,D
3. Access Mostly Uused Products by 50000+ Subscribers
4. D,E,F

5. A,B,D


Correct Answer : Get Lastest Questions and Answer :





Question : Which statement will empty the contents of a StringBuilder variable named sb?

 : Which statement will empty the contents of a StringBuilder variable named sb?
1. sb.deleteAll();
2. sb.delete(0, sb.size());
3. Access Mostly Uused Products by 50000+ Subscribers
4. sb.removeAll();



Correct Answer : Get Lastest Questions and Answer :





Question : Given the code fragment:
System.out.println(2 + 4 * 9 - 3); //Line 21
System.out.println((2 + 4) * 9 - 3); // Line 22
System.out.println(2 + (4 * 9) - 3); // Line 23
System.out.println(2 + 4 * (9 - 3)); // Line 24
System.out.println((2 + 4 * 9) - 3); // Line 25
Which line of codes prints the highest number?
 : Given the code fragment:
1. Line 21
2. Line 22
3. Access Mostly Uused Products by 50000+ Subscribers
4. Line 24

4. Line 25




Correct Answer : Get Lastest Questions and Answer : The following is printed: 35
35
35


Related Questions


Question : The catch clause argument is always of type .

A. Exception
B. Exception but NOT including RuntimeException
C. Throwable
D. RuntimeException
E. CheckedException


 : The catch clause argument is always of type .
1. A
2. B
3. Access Mostly Uused Products by 50000+ Subscribers
4. D
5. E





Question : You have been given following code

public class MainMethod {
void main() {
System.out.println("one");
}

static void main(String args) {
System.out.println("two");
}

public static void main(String[] args) {
System.out.println("three");
}

void mina(Object[] args) {
System.out.println("four");
}
}

What is printed out when the program is excuted?

 : You have been given following code
1. one
2. two
3. Access Mostly Uused Products by 50000+ Subscribers
4. four




Question : You have been given following code

int var1 = -5;
int var2 = var1--;
int var3 = 0;
if (var2 <lt; 0) {
var3 = var2++;
} else {
var3 = --var2;
}
System.out.println(var3);

What is the result?


 : You have been given following code
1. -6
2. -4
3. Access Mostly Uused Products by 50000+ Subscribers
4. 5

5. 4




Question : You have been given below code

public class FieldInit {
char c;
boolean b;
float f;

void printAll() {
System.out.println("c = " + c);
System.out.println("c = " + b);
System.out.println("c = " + f);
}

public static void main(String[] args) {
FieldInit f = new FieldInit();
f.printAll();
}
}

What would be result ?

 : You have been given below code
1. c = null
b = false
f = 0.0F
2. c = 0
b = false
f = 0.0f
3. Access Mostly Uused Products by 50000+ Subscribers
b = true
f = 0.0
4. c =
b = false
f = 0.0





Question : You have been given following code

int a = 0;
a++;
System.out.println(a++);
System.out.println(a);

What would be the result ?

 : You have been given following code
1. 1

2. 0

3. Access Mostly Uused Products by 50000+ Subscribers

4. 2





Question : You have been given following code

public class Test {
public static void main(String[] args) {
int arr[] = new int[4];
arr[0] = 1;
arr[1] = 2;
arr[2] = 4;
arr[3] = 5;
int sum = 0;
try {
for (int pos = 0; pos <= 4; pos++) {
sum = sum + arr[pos];
}
} catch (Exception e) {
System.out.println("Invalid index");
}
System.out.println(sum);
}
}

What would be printed ?
 : You have been given following code
1. 12
2. Invalid Index 12
3. Access Mostly Uused Products by 50000+ Subscribers
4. Compilation fails