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 11 of 32

Explore more Topics under Java Programming

Q101.
Which three are valid method signatures in an interface?

1. private int getArea();
2. public float getVol(float x);
3. public void main(String [] args);
4. public static void main(String [] args);
5. boolean setFlag(Boolean [] test);
Discuss
Answer: (b).2, 3 and 5
Q102.
You want a class to have access to members of another class in the same package. Which is the most restrictive access that accomplishes this objective?
Discuss
Answer: (d).default access
Q103.
What is the widest valid returnType for methodA in line 3?
 
public class ReturnIt 
{ 
    returnType methodA(byte x, double y) /* Line 3 */
    { 
        return (long)x / y * 2; 
    } 
}
Discuss
Answer: (d).double
Discuss
Answer: (a).public int method1(int a, int b) {return 0; }
Discuss
Answer: (a).int[ ] ia = new int[15];
Q106.
Which two of the following are legal declarations for nonnested classes and interfaces?

1. final abstract class Test {}
2. public static interface Test {}
3. final public class Test {}
4. protected abstract class Test {}
5. protected interface Test {}
6. abstract public class Test {}
Discuss
Answer: (c).3 and 6
Q107.
Which of the following class level (nonlocal) variable declarations will not compile?
Discuss
Answer: (c).private synchronized int e;
Q108.
What will be the output of the program?
 
interface Count 
{
    short counter = 0;
    void countUp();
}
public class TestCount implements Count 
{
    public static void main(String [] args) 
    {
        TestCount t = new TestCount();
        t.countUp();
    }
    public void countUp() 
    {
        for (int x = 6; x>counter; x--, ++counter) /* Line 14 */
        {
            System.out.print(" " + counter);
        }
    }
}
Discuss
Answer: (d).Compilation fails
Q109.
What will be the output of the program?

class Base
{ 
    Base()
    {
        System.out.print("Base");
    }
} 
public class Alpha extends Base
{ 
    public static void main(String[] args)
    { 
        new Alpha(); /* Line 12 */
        new Base(); /* Line 13 */
    } 
}
Discuss
Answer: (b).BaseBase
Q110.
What will be the output of the program?

import java.util.*;
public class NewTreeSet2 extends NewTreeSet 
{
    public static void main(String [] args) 
    {
        NewTreeSet2 t = new NewTreeSet2();
        t.count();
    }
}
protected class NewTreeSet
{
    void count() 
    {
        for (int x = 0; x < 7; x++,x++ ) 
        {
            System.out.print(" " + x);
        }
    }
}
Discuss
Answer: (d).Compilation fails at line 10

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!