Premium

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



Question : You have been given below declarations:

public abstract class Animal
public interface Hunter
public class Cat extends Animalimplements Hunter
public class Tiger extends Cat

Which answer fails to compile?

  : You have been given below declarations:
1. ArrayList myList1 = new ArrayList<>();
myList1.add(new Tiger());
2. ArrayList myList2 = new ArrayList<>();
myList2.add(new Cat());
3. Access Mostly Uused Products by 50000+ Subscribers
myList3.add(new Tiger());
4. ArrayList myList4 = new ArrayList<>();
myList4.add(new Cat());
5. ArrayList myList = new ArrayList<>();
myList.add(new Cat());




Correct Answer : Get Lastest Questions and Answer :
Explanation:







Question : Which statement is true about Java byte code?
 : Which statement is true about Java byte code?
1. It can run on any platform.
2. It can run on any platform only if it was compiled for that platform.
3. Access Mostly Uused Products by 50000+ Subscribers
4. It can run on any platform that has a Java compiler.
5. It can run on any platform only if that platform has both the Java Runtime Environment and a Java compiler.





Correct Answer : Get Lastest Questions and Answer :
Explanation:







Question :

public class MarkList {
int num;

public static void graceMarks(MarkList obj4) {
obj4.num += 10;
}

public static void main(String[] args) {
MarkList obj1 = new MarkList();
MarkList obj2 = obj1;
MarkList obj3 = null;
obj2.num = 60;
graceMarks(obj2);
}
}

How many MarkList instances are created in memory at runtime?

 :
1. 1
2. 2
3. Access Mostly Uused Products by 50000+ Subscribers
4. 4





Correct Answer : Get Lastest Questions and Answer :




Related Questions


Question : An unchecked exception occurs in a method dosomething() Should other code be added in the dosomething() method for it to compile and execute?

 : An unchecked exception occurs in a method dosomething() Should other code be added in the dosomething() method for it to compile and execute?
1. The Exception must be caught
2. The Exception must be declared to be thrown.
3. Access Mostly Uused Products by 50000+ Subscribers
4. No other code needs to be added.




Question : Which two statements are true for a two-dimensional array of primitive data type?
A. It cannot contain elements of different types.
B. The length of each dimension must be the same.
C. At the declaration time, the number of elements of the array in each dimension must be specified.
D. All methods of the class object may be invoked on the two-dimensional array.

 : Which two statements are true for a two-dimensional array of primitive data type?
1. A,B
2. B,C
3. Access Mostly Uused Products by 50000+ Subscribers
4. A,D




Question : A method is declared to take three arguments. A program calls this method and passes only two arguments. What is the result?

 : A method is declared to take three arguments. A program calls this method and passes only two arguments. What is the result?
1. Compilation fails.
2. The third argument is given the value null.
3. Access Mostly Uused Products by 50000+ Subscribers
4. The third argument is given the value zero.
5. The third argument is given the appropriate false value for its declared type.




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



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();




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