adplus-dvertising

Welcome to the Language Fundamentals MCQs Page

Dive deep into the fascinating world of Language Fundamentals with our comprehensive set of Multiple-Choice Questions (MCQs). This page is dedicated to exploring the fundamental concepts and intricacies of Language Fundamentals, a crucial aspect of Java Programming. In this section, you will encounter a diverse range of MCQs that cover various aspects of Language Fundamentals, 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 Language Fundamentals. 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 Language Fundamentals. You can click on an option to test your knowledge before viewing the solution for a MCQ. Happy learning!

Language Fundamentals MCQs | Page 2 of 10

Explore more Topics under Java Programming

Q11.
Which one of the following will declare an array and initialize it with five numbers?
Discuss
Answer: (b).int [] a = {23,22,21,20,19};
Q12.
Which three are valid declarations of a char?

1. char c1 = 064770;
2. char c2 = 'face';
3. char c3 = 0xbeef;
4. char c4 = \u0022;
5. char c5 = '\iface';
6. char c6 = '\uface';


Discuss
Answer: (b).1, 3, 6
Discuss
Answer: (a).public double methoda();
Q14.
What will be the output of the program?
Note: The command-line invocation is
> java CommandArgsThree 1 2 3

public class CommandArgsThree 
{
    public static void main(String [] args) 
    {
        String [][] argCopy = new String[2][2];
        int x;
        argCopy[0] = args;
        x = argCopy[0].length;
        for (int y = 0; y < x; y++) 
        {
            System.out.print(" " + argCopy[0][y]);
        }
    }
}
Discuss
Answer: (d).1 2 3
Q15.
What will be the output of the progra
Note: The command-line invocation is
> java CommandArgs 1 2 3 4

public class CommandArgs 
{
    public static void main(String [] args) 
    {
        String s1 = args[1];
        String s2 = args[2];
        String s3 = args[3];
        String s4 = args[4];
        System.out.print(" args[2] = " + s2);
    }
}
Discuss
Answer: (d).An exception is thrown at runtime.
Q16.
What will be the output of the program, if this code is executed with the command line:

> java F0091 world
public class F0091 
{    
    public void main( String[] args ) 
    {  
        System.out.println( "Hello" + args[0] ); 
    } 
}
Discuss
Answer: (d).The code does not run.
Q17.
What will be the output of the program?


public class TestDogs 
{
    public static void main(String [] args) 
    {
        Dog [][] theDogs = new Dog[3][];
        System.out.println(theDogs[2][0].toString());
    }
}
class Dog { }
Discuss
Answer: (d).An exception is thrown at runtime
Q18.
What will be the output of the program ?

public class Test 
{
    public static void main(String [] args) 
    {
        signed int x = 10;
        for (int y=0; y<5; y++, x--)
            System.out.print(x + ", ");
    }
}
Discuss
Answer: (c).Compilation fails.
Q19.
What will be the output of the program?

Note: The command-line invocation is
> java CommandArgsTwo 1 2 3

public class CommandArgsTwo 
{
    public static void main(String [] argh) 
    {
        int x;
        x = argh.length;
        for (int y = 1; y <= x; y++) 
        {
            System.out.print(" " + argh[y]);
        }
    }
}
Discuss
Answer: (d).An exception is thrown at runtime
Q20.
In the given program, how many lines of output will be produced?

public class Test 
{
    public static void main(String [] args) 
    {
    int [] [] [] x = new int [3] [] [];
    int i, j;
    x[0] = new int[4][];
    x[1] = new int[2][];
    x[2] = new int[5][];
    for (i = 0; i < x.length; i++)
    {
        for (j = 0; j < x[i].length; j++) 
        {
            x[i][j] = new int [i + j + 1];
            System.out.println("size = " + x[i][j].length);
        }
    }
    }
}
Discuss
Answer: (c).11

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!