adplus-dvertising

Welcome to the Data Types,Variables and Arrays MCQs Page

Dive deep into the fascinating world of Data Types,Variables and Arrays with our comprehensive set of Multiple-Choice Questions (MCQs). This page is dedicated to exploring the fundamental concepts and intricacies of Data Types,Variables and Arrays, a crucial aspect of Java Programming. In this section, you will encounter a diverse range of MCQs that cover various aspects of Data Types,Variables and Arrays, from the basic principles to advanced topics. Each question is thoughtfully crafted to challenge your knowledge and deepen your understanding of this critical subcategory within Java Programming.

frame-decoration

Check out the MCQs below to embark on an enriching journey through Data Types,Variables and Arrays. Test your knowledge, expand your horizons, and solidify your grasp on this vital area of Java Programming.

Note: Each MCQ comes with multiple answer choices. Select the most appropriate option and test your understanding of Data Types,Variables and Arrays. You can click on an option to test your knowledge before viewing the solution for a MCQ. Happy learning!

Data Types,Variables and Arrays MCQs | Page 13 of 32

Q121.
Which three statements are true?

1. The default constructor initialises method variables.
2. The default constructor has the same access as its class.
3. The default constructor invokes the no-arg constructor of the superclass.
4. If a class lacks a no-arg constructor, the compiler always creates a default constructor.
5. The compiler creates a default constructor only when there are no other constructors for the class.
Discuss
Answer: (b).2, 3 and 5
Q122.

Which statement is true?
package testpkg.p1;
public class ParentUtil 
{
    public int x = 420;
    protected int doStuff() { return x; }
}

package testpkg.p2;
import testpkg.p1.ParentUtil;
public class ChildUtil extends ParentUtil 
{
    public static void main(String [] args) 
    {
        new ChildUtil().callStuff();
    }
    void callStuff() 
    {
        System.out.print("this " + this.doStuff() ); /* Line 18 */
        ParentUtil p = new ParentUtil();
        System.out.print(" parent " + p.doStuff() ); /* Line 20 */
    }
}
Discuss
Answer: (c).If line 20 is removed, the code will compile and run.
Q123.
What is the numerical range of char?
Discuss
Answer: (b).0 to 65535
Q124.
Which of the following are Java reserved words?

1. run
2. import
3. default
4. implement
Discuss
Answer: (b).2 and 3
Q125.
Suppose that you would like to create an instance of a new Map that has an iteration order that is the same as the iteration order of an existing instance of a Map. Which concrete implementation of the Map interface should be used for the new instance?
Discuss
Answer: (c).LinkedHashMap
Q126.
Which class does not override the equals() and hashCode() methods, inheriting them directly from class Object?
Discuss
Answer: (c).java.lang.StringBuffer
Q127.
Which collection class allows you to grow or shrink its size and provides indexed access to its elements, but whose methods are not synchronized?
Discuss
Answer: (d).java.util.ArrayList
Q128.
You need to store elements in a collection that guarantees that no duplicates are stored and all elements can be accessed in natural order. Which interface provides that capability?
Discuss
Answer: (b).java.util.Set
Q129.
Which interface does java.util.Hashtable implement?
Discuss
Answer: (a).Java.util.Map
Q130.
Which interface provides the capability to store objects using a key-value pair?
Discuss
Answer: (a).Java.util.Map

Suggested Topics

Are you eager to expand your knowledge beyond Java Programming? We've curated a selection of related categories that you might find intriguing.

Click on the categories below to discover a wealth of MCQs and enrich your understanding of Computer Science. Happy exploring!