Premium

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



Question : Identify two benefits of using ArrayList over array in software development.
A. reduces memory footprint
B. implements the Collection API
C. is multithread safe
D. dynamically resizes based on the number of elements in the list



 : Identify two benefits of using ArrayList over array in software development.
1. A,B
2. A,D
3. Access Mostly Uused Products by 50000+ Subscribers
4. C,D




Correct Answer : Get Lastest Questions and Answer :

Explanation: ArrayList supports dynamic arrays that can grow as needed. In Java, standard arrays are of a
fixed length. After arrays are created, they cannot grow or shrink, which means that you must
know in advance how many elements an array will hold. But, sometimes, you may not know
until run time precisely how large of an array you need. To handle this situation, the
collections framework defines ArrayList. In essence, an ArrayList is a variable-length array
of object references. That is, an ArrayList can dynamically increase or decrease in size.
Array lists are created with an initial size. When this size is exceeded, the collection is
automatically enlarged. When objects are removed, the array may be shrunk.





Question : You have been given below code


Public Class Test {}

Which two packages are automatically imported into the java source file by the java compiler?s

A. Java.lang
B. Java.awt
C. Java.util
D. Javax.net
E. Java.*
F. The package with no name


  :  You have been given below code
1. A,B
2. A,F
3. Access Mostly Uused Products by 50000+ Subscribers
4. C,D
5. E,F





Correct Answer : Get Lastest Questions and Answer :
Epe : For convenience, the Java compiler automatically imports three entire packages for each
source file: (1) the package with no name, (2) the java.lang package, and (3) the current
package (the package for the current file).
Note:Packages in the Java language itself begin with java. or javax.






Question : Which is a valid abstract class?

 : Which is a valid abstract class?
1. public abstract class Car { protected void accelerate();}
2. public interface Car {protected abstract void accelerate();}
3. Access Mostly Uused Products by 50000+ Subscribers
4. public abstract class Car { protected abstract void accelerate();}

5. public abstract class Car { protected abstract void accelerate() { //more car can do}}





Correct Answer : Get Lastest Questions and Answer :


Related Questions


Question : : Which statement best describes encapsulation?
 :  : Which statement best describes encapsulation?
1. Encapsulation ensures that classes can be designed so that only certain fields and methods of an object are accessible from other objects.
2. Encapsulation ensures that classes can be designed so that their methods are inheritable.
3. Encapsulation ensures that classes can be designed with some fields and methods declared as abstract.
4. Encapsulation ensures that classes can be designed so that if a method has an argument MyType x, any subclass of MyType can be passed to that method.



Question : Given the code fragment:

int a[] = {1,2,3,4,5};

for(XXX){
System.out.print(a[e]);
}

Which option can replace xxx to enable the code to print 24?

 :   Given the code fragment:
1. int e = 0; e<=4; e++
2. int e = 1; e<5; e+=2
3. int e = 1; e<=5; e+=1
4. int e = 1; e<5; e+=2




Question : Given:

And given code fragment :

DVD dvd = new DVD(10,20)

Which code fragment should you use at line n1 to instantiate the dvd object successfully?
 :  Given:
1. super.r =r;
this.c = c;
2. super(r);
this(c);
3. super(r);
this.c = c;

4. this.c=r;
super(c);



Question : Given:

public static void main(String args[]){

String ta = "A ";
ta = ta.concat("B ");
String tb = "C ";
ta= ta.concat(tb);
ta.replace('C', 'D');
ta=ta.concat(tb);
System.out.println(ta);

}

What is the result?

 :   Given:
1. A B C D
2. A C D
3. A B C C
4. A B D
5. A B D C



Question : Given:
Which option enables the code to compile?
 :  Given:
1. Replace the code fragment at line n1 with :
class Book implements Readable {
2. At line n2 insert :
public abstract void setBookMark();
3. Replace the code fragment at line n3 with :
abstract class EBook extends Book {
4. At line n4 insert:
public void setBookMark() {}



Question : Given the code fragment:
What is the result?
 :  Given the code fragment:
1. Match 1
2. Match 2
3. No Match
4. A NullPointerException is thrown at runtime.