SlideShare a Scribd company logo
2
Most read
5
Most read
9
Most read
Rumman Ansari || www.atnyla.com Java Language Fundamental
Java Language Fundamental
MCQ Question and Answer
Note: Click to the question to know the answer from our website
www.atnyla.com
Rumman Ansari || www.atnyla.com Java Language Fundamental
Q Java is a _________ language.
A. weakly typed
B. strogly typed
C. moderate typed
D. None of these
View Answer
Q Which is a valid keyword in java?
A. interface
B. string
C. Float
D. unsigned
View Answer
Q Which is a reserved word in the Java programming language?
A. method
B. native
C. subclasses
D. reference
View Answer
Q Which will legally declare, construct, and initialize an array?
A. int [] myList = {"1", "2", "3"};
B. int [] myList = (5, 8, 2);
C. int myList [] [] = {4,9,7,0};
D. int myList [] = {4, 3, 7};
View Answer
Q Which one of these lists contains only Java programming language
keywords?
A. class, if, void, long, Int, continue
B. goto, instanceof, native, finally, default, throws
C. try, virtual, throw, final, volatile, transient
D. strictfp, constant, super, implements, do
View Answer
Q Which four options describe the correct default values for array elements of
the types indicated?
1. int -> 0
2. String -> "null"
3. Dog -> null
4. char -> 'u0000'
Rumman Ansari || www.atnyla.com Java Language Fundamental
5. float -> 0.0f
6. boolean -> true
A. 1, 2, 3, 4
B. 1, 3, 4, 5
C. 2, 4, 5, 6
D. 3, 4, 5, 6
View Answer
Q Which three are legal array declarations?
1. int [] myScores [];
2. char [] myChars;
3. int [6] myScores;
4. Dog myDogs [];
5. Dog myDogs [7];
A. 1, 2, 4
B. 2, 4, 5
C. 2, 3, 4
D. All are correct.
View Answer
Q
public interface Foo
{
int k = 4; /* Line 3 */
}
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;
Rumman Ansari || www.atnyla.com Java Language Fundamental
A. 1, 2 and 3
B. 2, 3 and 4
C. 3, 4 and 5
D. 4, 5 and 6
View Answer
Q Which one of the following will declare an array and initializeit with five
numbers?
A. Array a = new Array(5);
B. int [] a = {23,22,21,20,19};
C. int a [] = new int[5];
D. int [5] array;
View Answer
Q 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';
A. 1, 2, 4
B. 1, 3, 6
C. 3, 5
D. 5 only
View Answer
Q Which is the valid declarations within an interface definition?
A. public double methoda();
B. public final double methoda();
C. static void methoda(double d1);
D. protected void methoda(double d1);
View Answer
Q Which one is a valid declaration of a boolean?
A. boolean b1 = 0;
B. boolean b2 = 'false';
C. boolean b3 = false;
Rumman Ansari || www.atnyla.com Java Language Fundamental
D. boolean b4 = Boolean.false();
View Answer
Q 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;
A. 1, 2, 4
B. 2, 3, 5
C. 1, 3, 6
D. 2, 4, 6
View Answer
Q Which is a valid declarations of a String?
A. String s1 = null;
B. String s2 = 'null';
C. String s3 = (String) 'abc';
D. String s4 = (String) 'ufeed';
View Answer
Q What is the numerical range of a char?
A. -128 to 127
B. -(215) to (215) - 1
C. 0 to 32767
D. 0 to 65535
View Answer
Q What will be the output of the program?
public class CommandArgsThree
{
public static void main(String [] args)
{
String [][] argCopy = new String[2][2];
int x;
argCopy[0] = args;
Rumman Ansari || www.atnyla.com Java Language Fundamental
x = argCopy[0].length;
for (int y = 0; y < x; y++)
{
System.out.print(" " + argCopy[0][y]);
}
}
}
What will be the output of the program? public class CommandArgsThree {
publ
A. 0 0
B. 1 2
C. 0 0 0
D. 1 2 3
View Answer
Q What will be the output of the program?
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);
}
}
and the command-line invocation is > java CommandArgs 1 2 3 4
A. args[2] = 2
B. args[2] = 3
C. args[2] = null
D. An exception is thrown at runtime.
View Answer
Q
public class F0091
Rumman Ansari || www.atnyla.com Java Language Fundamental
{
public void main( String[] args )
{
System.out.println( "Hello" + args[0] );
}
}
What will be the output of the program, if this code is executed with the
command line: > java F0091 world
A. Hello
B. Hello Foo91
C. Hello world
D. The code does not run.
View Answer
Q 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 { }
A. null
B. theDogs
C. Compilation fails
D. An exception is thrown at runtime
View Answer
Q What will be the output of the program ?
public class Test
{
public static void main(String [] args)
{
Rumman Ansari || www.atnyla.com Java Language Fundamental
signed int x = 10;
for (int y=0; y<5; y++, x--)
System.out.print(x + ", ");
}
}
A. 10, 9, 8, 7, 6,
B. 9, 8, 7, 6, 5,
C. Compilation fails.
D. An exception is thrown at runtime.
View Answer
Q What will be the output of the program?
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]);
}
}
}
and the command-line invocation is
> java CommandArgsTwo 1 2 3
A. 0 1 2
B. 1 2 3
C. 0 0 0
D. An exception is thrown at runtime
View Answer
Q In the given program, how many lines of output will be produced?
Rumman Ansari || www.atnyla.com Java Language Fundamental
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].leng
A. 7
B. 9
C. 11
D. 13
View Answer
Q What will be the output of the program?
public class X
{
public static void main(String [] args)
{
String names [] = new String[5];
for (int x=0; x < args.length; x++)
names[x] = args[x];
System.out.println(names[2]);
}
}
and the command line invocation is
> java X a b
Rumman Ansari || www.atnyla.com Java Language Fundamental
A. names
B. null
C. Compilation fails
D. An exception is thrown at runtime
View Answer
Q Size of int in Java is
A. 16 bit
B. 32 bit
C. 64 bit
D. Depends on execution environment
View Answer
Q The implicit return type of a constructor is
A. void
B. A class object in which it is defined.
C. There is no return type.
D. None of the above
View Answer

More Related Content

PPTX
Functional Patterns with Java8 @Bucharest Java User Group
PDF
Java 8 Lambda Expressions
PDF
Core java
PDF
PPSX
Collections - Lists, Sets
PPTX
Java web application development
DOCX
Unit i software design principles 9
PPTX
Unit Testing in Java
Functional Patterns with Java8 @Bucharest Java User Group
Java 8 Lambda Expressions
Core java
Collections - Lists, Sets
Java web application development
Unit i software design principles 9
Unit Testing in Java

What's hot (20)

PPT
Exception Handling in JAVA
PDF
Android Service Intro
PPT
Java servlets
PPTX
Data driven Automation Framework with Selenium
PPSX
PPT
Java Swing JFC
PPTX
Spring Framework Petclinic sample application
PPTX
Spring boot
PPT
Method overloading
PPTX
Event driven theory
DOCX
Data structures and algorithms unit i
PDF
Collections Api - Java
PPTX
Java Server Pages
DOCX
Multiple choice questions for Java io,files and inheritance
PPTX
Clean Pragmatic Architecture - Avoiding a Monolith
PPTX
Java database connectivity with MySql
PDF
200 mcq c++(Ankit dubey)
PPTX
Database in Android
PPTX
SUBQUERIES.pptx
Exception Handling in JAVA
Android Service Intro
Java servlets
Data driven Automation Framework with Selenium
Java Swing JFC
Spring Framework Petclinic sample application
Spring boot
Method overloading
Event driven theory
Data structures and algorithms unit i
Collections Api - Java
Java Server Pages
Multiple choice questions for Java io,files and inheritance
Clean Pragmatic Architecture - Avoiding a Monolith
Java database connectivity with MySql
200 mcq c++(Ankit dubey)
Database in Android
SUBQUERIES.pptx
Ad

Similar to Java Questions and Answers (20)

PDF
Fnt software solutions placement paper
PDF
Oracle Certified Associate (OCA) Java SE 8 Programmer II (1Z0-809) - Practice...
PDF
Java MCQ Questions and Answers PDF By ScholarHat
DOCX
FSOFT - Test Java Exam
PPTX
Top 20 java programming interview questions for sdet
PPTX
UNIT 2 LOOP CONTROL.pptx
PPT
Questões de Certificação SCJP
PPT
Conceitos Fundamentais de Orientação a Objetos
PPTX
Java Quiz
PPT
Java language fundamentals
RTF
PDF
1z0 851 exam-java standard edition 6 programmer certified professional
PDF
Java Programming.pdf
PDF
Java Question-Bank-Class-8.pdf
PDF
Starting Out with Java From Control Structures through Objects 6th Edition Ga...
PDF
1z0-808-certification-questions-sample
PDF
Google Interview Questions By Scholarhat
DOC
Fnt software solutions placement paper
Oracle Certified Associate (OCA) Java SE 8 Programmer II (1Z0-809) - Practice...
Java MCQ Questions and Answers PDF By ScholarHat
FSOFT - Test Java Exam
Top 20 java programming interview questions for sdet
UNIT 2 LOOP CONTROL.pptx
Questões de Certificação SCJP
Conceitos Fundamentais de Orientação a Objetos
Java Quiz
Java language fundamentals
1z0 851 exam-java standard edition 6 programmer certified professional
Java Programming.pdf
Java Question-Bank-Class-8.pdf
Starting Out with Java From Control Structures through Objects 6th Edition Ga...
1z0-808-certification-questions-sample
Google Interview Questions By Scholarhat
Ad

More from Rumman Ansari (20)

PDF
Sql tutorial
PDF
C programming exercises and solutions
PDF
Java Tutorial best website
DOCX
servlet programming
PPTX
C program to write c program without using main function
PPTX
Steps for c program execution
PPTX
Pointer in c program
PPTX
My first program in c, hello world !
PPTX
How c program execute in c program
PPTX
What is token c programming
PPTX
What is identifier c programming
PPTX
What is keyword in c programming
PPTX
Type casting in c programming
PPTX
C Programming Language Part 11
PPTX
C Programming Language Part 9
PPTX
C Programming Language Part 8
PPTX
C Programming Language Part 7
PPTX
C Programming Language Part 6
PPTX
C Programming Language Part 5
PPTX
C Programming Language Part 4
Sql tutorial
C programming exercises and solutions
Java Tutorial best website
servlet programming
C program to write c program without using main function
Steps for c program execution
Pointer in c program
My first program in c, hello world !
How c program execute in c program
What is token c programming
What is identifier c programming
What is keyword in c programming
Type casting in c programming
C Programming Language Part 11
C Programming Language Part 9
C Programming Language Part 8
C Programming Language Part 7
C Programming Language Part 6
C Programming Language Part 5
C Programming Language Part 4

Recently uploaded (20)

PPTX
Programs and apps: productivity, graphics, security and other tools
PDF
Network Security Unit 5.pdf for BCA BBA.
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PPTX
MYSQL Presentation for SQL database connectivity
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PDF
cuic standard and advanced reporting.pdf
PDF
Encapsulation theory and applications.pdf
PPTX
Cloud computing and distributed systems.
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PDF
gpt5_lecture_notes_comprehensive_20250812015547.pdf
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PDF
Assigned Numbers - 2025 - Bluetooth® Document
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PDF
Spectral efficient network and resource selection model in 5G networks
PPTX
sap open course for s4hana steps from ECC to s4
PDF
Review of recent advances in non-invasive hemoglobin estimation
Programs and apps: productivity, graphics, security and other tools
Network Security Unit 5.pdf for BCA BBA.
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
Agricultural_Statistics_at_a_Glance_2022_0.pdf
Chapter 3 Spatial Domain Image Processing.pdf
MYSQL Presentation for SQL database connectivity
“AI and Expert System Decision Support & Business Intelligence Systems”
cuic standard and advanced reporting.pdf
Encapsulation theory and applications.pdf
Cloud computing and distributed systems.
Per capita expenditure prediction using model stacking based on satellite ima...
gpt5_lecture_notes_comprehensive_20250812015547.pdf
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
Assigned Numbers - 2025 - Bluetooth® Document
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
Dropbox Q2 2025 Financial Results & Investor Presentation
Advanced methodologies resolving dimensionality complications for autism neur...
Spectral efficient network and resource selection model in 5G networks
sap open course for s4hana steps from ECC to s4
Review of recent advances in non-invasive hemoglobin estimation

Java Questions and Answers

  • 1. Rumman Ansari || www.atnyla.com Java Language Fundamental Java Language Fundamental MCQ Question and Answer Note: Click to the question to know the answer from our website www.atnyla.com
  • 2. Rumman Ansari || www.atnyla.com Java Language Fundamental Q Java is a _________ language. A. weakly typed B. strogly typed C. moderate typed D. None of these View Answer Q Which is a valid keyword in java? A. interface B. string C. Float D. unsigned View Answer Q Which is a reserved word in the Java programming language? A. method B. native C. subclasses D. reference View Answer Q Which will legally declare, construct, and initialize an array? A. int [] myList = {"1", "2", "3"}; B. int [] myList = (5, 8, 2); C. int myList [] [] = {4,9,7,0}; D. int myList [] = {4, 3, 7}; View Answer Q Which one of these lists contains only Java programming language keywords? A. class, if, void, long, Int, continue B. goto, instanceof, native, finally, default, throws C. try, virtual, throw, final, volatile, transient D. strictfp, constant, super, implements, do View Answer Q Which four options describe the correct default values for array elements of the types indicated? 1. int -> 0 2. String -> "null" 3. Dog -> null 4. char -> 'u0000'
  • 3. Rumman Ansari || www.atnyla.com Java Language Fundamental 5. float -> 0.0f 6. boolean -> true A. 1, 2, 3, 4 B. 1, 3, 4, 5 C. 2, 4, 5, 6 D. 3, 4, 5, 6 View Answer Q Which three are legal array declarations? 1. int [] myScores []; 2. char [] myChars; 3. int [6] myScores; 4. Dog myDogs []; 5. Dog myDogs [7]; A. 1, 2, 4 B. 2, 4, 5 C. 2, 3, 4 D. All are correct. View Answer Q public interface Foo { int k = 4; /* Line 3 */ } 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;
  • 4. Rumman Ansari || www.atnyla.com Java Language Fundamental A. 1, 2 and 3 B. 2, 3 and 4 C. 3, 4 and 5 D. 4, 5 and 6 View Answer Q Which one of the following will declare an array and initializeit with five numbers? A. Array a = new Array(5); B. int [] a = {23,22,21,20,19}; C. int a [] = new int[5]; D. int [5] array; View Answer Q 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'; A. 1, 2, 4 B. 1, 3, 6 C. 3, 5 D. 5 only View Answer Q Which is the valid declarations within an interface definition? A. public double methoda(); B. public final double methoda(); C. static void methoda(double d1); D. protected void methoda(double d1); View Answer Q Which one is a valid declaration of a boolean? A. boolean b1 = 0; B. boolean b2 = 'false'; C. boolean b3 = false;
  • 5. Rumman Ansari || www.atnyla.com Java Language Fundamental D. boolean b4 = Boolean.false(); View Answer Q 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; A. 1, 2, 4 B. 2, 3, 5 C. 1, 3, 6 D. 2, 4, 6 View Answer Q Which is a valid declarations of a String? A. String s1 = null; B. String s2 = 'null'; C. String s3 = (String) 'abc'; D. String s4 = (String) 'ufeed'; View Answer Q What is the numerical range of a char? A. -128 to 127 B. -(215) to (215) - 1 C. 0 to 32767 D. 0 to 65535 View Answer Q What will be the output of the program? public class CommandArgsThree { public static void main(String [] args) { String [][] argCopy = new String[2][2]; int x; argCopy[0] = args;
  • 6. Rumman Ansari || www.atnyla.com Java Language Fundamental x = argCopy[0].length; for (int y = 0; y < x; y++) { System.out.print(" " + argCopy[0][y]); } } } What will be the output of the program? public class CommandArgsThree { publ A. 0 0 B. 1 2 C. 0 0 0 D. 1 2 3 View Answer Q What will be the output of the program? 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); } } and the command-line invocation is > java CommandArgs 1 2 3 4 A. args[2] = 2 B. args[2] = 3 C. args[2] = null D. An exception is thrown at runtime. View Answer Q public class F0091
  • 7. Rumman Ansari || www.atnyla.com Java Language Fundamental { public void main( String[] args ) { System.out.println( "Hello" + args[0] ); } } What will be the output of the program, if this code is executed with the command line: > java F0091 world A. Hello B. Hello Foo91 C. Hello world D. The code does not run. View Answer Q 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 { } A. null B. theDogs C. Compilation fails D. An exception is thrown at runtime View Answer Q What will be the output of the program ? public class Test { public static void main(String [] args) {
  • 8. Rumman Ansari || www.atnyla.com Java Language Fundamental signed int x = 10; for (int y=0; y<5; y++, x--) System.out.print(x + ", "); } } A. 10, 9, 8, 7, 6, B. 9, 8, 7, 6, 5, C. Compilation fails. D. An exception is thrown at runtime. View Answer Q What will be the output of the program? 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]); } } } and the command-line invocation is > java CommandArgsTwo 1 2 3 A. 0 1 2 B. 1 2 3 C. 0 0 0 D. An exception is thrown at runtime View Answer Q In the given program, how many lines of output will be produced?
  • 9. Rumman Ansari || www.atnyla.com Java Language Fundamental 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].leng A. 7 B. 9 C. 11 D. 13 View Answer Q What will be the output of the program? public class X { public static void main(String [] args) { String names [] = new String[5]; for (int x=0; x < args.length; x++) names[x] = args[x]; System.out.println(names[2]); } } and the command line invocation is > java X a b
  • 10. Rumman Ansari || www.atnyla.com Java Language Fundamental A. names B. null C. Compilation fails D. An exception is thrown at runtime View Answer Q Size of int in Java is A. 16 bit B. 32 bit C. 64 bit D. Depends on execution environment View Answer Q The implicit return type of a constructor is A. void B. A class object in which it is defined. C. There is no return type. D. None of the above View Answer