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
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
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?
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}}
Question : : 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.
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? 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() {}