Java Language Fundamentals Mcqs
Our collections of Multiple choice questions and answers focuses on study of Java Language Fundamentals. These questions are chosen from a collection of most authoritative and best reference books on Java. Our aim is to prepare an individual for competitive exams like NTS, GAT, ECAT, University and College entrance exams and various tests and job interviews. One should practice our Mcqs to assimilate Java Language Fundamentals topic comprehensively.
Java Programming Mcqs
- Data Types Variables and Arrays Mcqs
- Exception Handling in Java Mcqs
- Interfaces and Packages Mcqs
- Java Classes and Methods Mcqs
- Java Event Handling Mcqs
- Java Inheritance Mcqs
- Java IO and Applets Mcqs
- java lang and java io Mcqs
- Java Language Fundamentals Mcqs
- Java Operators and Control Statements Mcqs
- java utilities Mcqs
- Miscellaneous Topics in Java Mcqs
- Multithreading in Java Mcqs
- Serialization and Networking Mcqs
- Session Management and JSP and Servlet Mcqs
- String Handling
Computer MCQS
Sciences MCQS
2. Which will legally declare, construct, and initialize an array?
Int [] myList = {"1", "2", "3"};
Int [] myList = (5, 8, 2);
Int myList [] [] = {4,9,7,0};
Int myList [] = {4, 3, 7};
Answer & Solution
No Solution for this Answer..! Report or Discus this Question
3. Which is a reserved word in the Java programming language?
Method
Native
Subclasses
Reference
4. Which is a valid keyword in java?
Interface
String
Float
Unsigned
Answer & Solution
No Solution for this Answer..! Report or Discus this Question
5. Which three are valid declarations of a float? 1. float f1 = -343;
2. float f2 = 3.14;
3. float f3 = 0x12345;
4. float f4 = 42e7;
5. float f5 = 2001.0D;
6. float f6 = 2.81F;
1. float f1 = -343;
2. float f2 = 3.14;
3. float f3 = 0x12345;
4. float f4 = 42e7;
5. float f5 = 2001.0D;
6. float f6 = 2.81F;
1, 2, 4
2, 3, 5
1, 3, 6
2, 4, 6
6. What is the numerical range of a char?
-128 to 127
-(2^15) to (2^15) - 1
0 to 32767
0 to 65535
Answer & Solution
No Solution for this Answer..! Report or Discus this Question
7. Which three are legal array declarations? 1. int [] myScores [];
2. char [] myChars;
3. int [6] myScores;
4. Dog myDogs [];
5. Dog myDogs [7];
1. int [] myScores [];
2. char [] myChars;
3. int [6] myScores;
4. Dog myDogs [];
5. Dog myDogs [7];
1, 2, 4
2, 4, 5
2, 3, 4
All are correct.
8. Which three piece of codes are equivalent to line 3? 1. final int k = 4;
2. public int k = 4;
3. static int k = 4;
4. abstract int k = 4;
5. volatile int k = 4;
6. protected int k = 4;
public interface Foo
{
int k = 4; /* Line 3 */
}
1. final int k = 4;
2. public int k = 4;
3. static int k = 4;
4. abstract int k = 4;
5. volatile int k = 4;
6. protected int k = 4;
public interface Foo
{
int k = 4; /* Line 3 */
}
1, 2 and 3
2, 3 and 4
3, 4 and 5
4, 5 and 6
Answer & Solution
No Solution for this Answer..! Report or Discus this Question
9. Which one of the following will declare an array and initialize it with five numbers?
Array a = new Array(5);
Int [] a = {23,22,21,20,19};
Int a [] = new int[5];
Int [5] array;
Answer & Solution
No Solution for this Answer..! Report or Discus this Question
10. Which is the valid declarations within an interface definition?
Public double methoda();
Public final double methoda();
Static void methoda(double d1);
Protected void methoda(double d1);
Answer & Solution
No Solution for this Answer..! Report or Discus this Question
11. What will be the output of the program? Note: The command-line invocation > 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]);
}
}
}
Note: The command-line invocation > 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]);
}
}
}
0 0
1 2
0 0 0
1 2 3
12. 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);
}
}
> 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);
}
}
Args[2] = 2
Args[2] = 3
Args[2] = null
An exception is thrown at runtime.
Answer & Solution
No Solution for this Answer..! Report or Discus this Question
13. 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] );
}
}
> java F0091 world
public class F0091
{
public void main( String[] args )
{
System.out.println( "Hello" + args[0] );
}
}
Hello
Hello Foo91
Hello world
The code does not run.
Answer & Solution
No Solution for this Answer..! Report or Discus this Question
14. 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 { }
public class TestDogs
{
public static void main(String [] args)
{
Dog [][] theDogs = new Dog[3][];
System.out.println(theDogs[2][0].toString());
}
}
class Dog { }
Null
TheDogs
Compilation fails
An exception is thrown at runtime
Answer & Solution
No Solution for this Answer..! Report or Discus this Question
15. 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 + ", ");
}
}
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 + ", ");
}
}
10, 9, 8, 7, 6,
9, 8, 7, 6, 5,
Compilation fails.
An exception is thrown at runtime.
Answer & Solution
No Solution for this Answer..! Report or Discus this Question