SlideShare a Scribd company logo
1 of 10
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

What's hot

What's hot (19)

Pj01 4-operators and control flow
Pj01 4-operators and control flowPj01 4-operators and control flow
Pj01 4-operators and control flow
 
Aptitute question papers in c
Aptitute question papers in cAptitute question papers in c
Aptitute question papers in c
 
Chapter 2 Java Methods
Chapter 2 Java MethodsChapter 2 Java Methods
Chapter 2 Java Methods
 
20.1 Java working with abstraction
20.1 Java working with abstraction20.1 Java working with abstraction
20.1 Java working with abstraction
 
Cbse marking scheme 2006 2011
Cbse marking scheme 2006  2011Cbse marking scheme 2006  2011
Cbse marking scheme 2006 2011
 
20.2 Java inheritance
20.2 Java inheritance20.2 Java inheritance
20.2 Java inheritance
 
Trie Data Structure
Trie Data StructureTrie Data Structure
Trie Data Structure
 
12. Java Exceptions and error handling
12. Java Exceptions and error handling12. Java Exceptions and error handling
12. Java Exceptions and error handling
 
C aptitude
C aptitudeC aptitude
C aptitude
 
13slide graphics
13slide graphics13slide graphics
13slide graphics
 
Qno 1 (f)
Qno 1 (f)Qno 1 (f)
Qno 1 (f)
 
An Argumentation-based Approach for Explaining Goal Selection in Intelligent ...
An Argumentation-based Approach for Explaining Goal Selection in Intelligent ...An Argumentation-based Approach for Explaining Goal Selection in Intelligent ...
An Argumentation-based Approach for Explaining Goal Selection in Intelligent ...
 
Repair dagstuhl jan2017
Repair dagstuhl jan2017Repair dagstuhl jan2017
Repair dagstuhl jan2017
 
14. Java defining classes
14. Java defining classes14. Java defining classes
14. Java defining classes
 
Trie Data Structure
Trie Data StructureTrie Data Structure
Trie Data Structure
 
16. Java stacks and queues
16. Java stacks and queues16. Java stacks and queues
16. Java stacks and queues
 
Lab manual data structure (cs305 rgpv) (usefulsearch.org) (useful search)
Lab manual data structure (cs305 rgpv) (usefulsearch.org)  (useful search)Lab manual data structure (cs305 rgpv) (usefulsearch.org)  (useful search)
Lab manual data structure (cs305 rgpv) (usefulsearch.org) (useful search)
 
Martin Chapman: Research Overview, 2017
Martin Chapman: Research Overview, 2017Martin Chapman: Research Overview, 2017
Martin Chapman: Research Overview, 2017
 
Practices For Becoming A Better Programmer
Practices For Becoming A Better ProgrammerPractices For Becoming A Better Programmer
Practices For Becoming A Better Programmer
 

Similar to Java Questions and Answers

2 object orientation-copy
2 object orientation-copy2 object orientation-copy
2 object orientation-copy
Joel Campos
 

Similar to Java Questions and Answers (20)

FSOFT - Test Java Exam
FSOFT - Test Java ExamFSOFT - Test Java Exam
FSOFT - Test Java Exam
 
Core java
Core javaCore java
Core java
 
UNIT 2 LOOP CONTROL.pptx
UNIT 2 LOOP CONTROL.pptxUNIT 2 LOOP CONTROL.pptx
UNIT 2 LOOP CONTROL.pptx
 
Conceitos Fundamentais de Orientação a Objetos
Conceitos Fundamentais de Orientação a ObjetosConceitos Fundamentais de Orientação a Objetos
Conceitos Fundamentais de Orientação a Objetos
 
Questões de Certificação SCJP
Questões de Certificação SCJPQuestões de Certificação SCJP
Questões de Certificação SCJP
 
Java language fundamentals
Java language fundamentalsJava language fundamentals
Java language fundamentals
 
Ansi c
Ansi cAnsi c
Ansi c
 
1z0 851 exam-java standard edition 6 programmer certified professional
1z0 851 exam-java standard edition 6 programmer certified professional1z0 851 exam-java standard edition 6 programmer certified professional
1z0 851 exam-java standard edition 6 programmer certified professional
 
Java Programming.pdf
Java Programming.pdfJava Programming.pdf
Java Programming.pdf
 
Java Question-Bank-Class-8.pdf
Java Question-Bank-Class-8.pdfJava Question-Bank-Class-8.pdf
Java Question-Bank-Class-8.pdf
 
1z0-808-certification-questions-sample
1z0-808-certification-questions-sample1z0-808-certification-questions-sample
1z0-808-certification-questions-sample
 
C test
C testC test
C test
 
Core java Essentials
Core java EssentialsCore java Essentials
Core java Essentials
 
Java concurrency questions and answers
Java concurrency questions and answers Java concurrency questions and answers
Java concurrency questions and answers
 
Simulado java se 7 programmer
Simulado java se 7 programmerSimulado java se 7 programmer
Simulado java se 7 programmer
 
sample_midterm.pdf
sample_midterm.pdfsample_midterm.pdf
sample_midterm.pdf
 
Part - 2 Cpp programming Solved MCQ
Part - 2  Cpp programming Solved MCQ Part - 2  Cpp programming Solved MCQ
Part - 2 Cpp programming Solved MCQ
 
2 object orientation-copy
2 object orientation-copy2 object orientation-copy
2 object orientation-copy
 
Multiple choice questions for Java io,files and inheritance
Multiple choice questions for Java io,files and inheritanceMultiple choice questions for Java io,files and inheritance
Multiple choice questions for Java io,files and inheritance
 
Review Questions for Exam 10182016 1. public class .pdf
Review Questions for Exam 10182016 1. public class .pdfReview Questions for Exam 10182016 1. public class .pdf
Review Questions for Exam 10182016 1. public class .pdf
 

More from Rumman Ansari

More from Rumman Ansari (20)

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

Recently uploaded

Recently uploaded (20)

"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptx
 
WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering Developers
 
WSO2 Micro Integrator for Enterprise Integration in a Decentralized, Microser...
WSO2 Micro Integrator for Enterprise Integration in a Decentralized, Microser...WSO2 Micro Integrator for Enterprise Integration in a Decentralized, Microser...
WSO2 Micro Integrator for Enterprise Integration in a Decentralized, Microser...
 
Introduction to use of FHIR Documents in ABDM
Introduction to use of FHIR Documents in ABDMIntroduction to use of FHIR Documents in ABDM
Introduction to use of FHIR Documents in ABDM
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
ChatGPT and Beyond - Elevating DevOps Productivity
ChatGPT and Beyond - Elevating DevOps ProductivityChatGPT and Beyond - Elevating DevOps Productivity
ChatGPT and Beyond - Elevating DevOps Productivity
 
Navigating Identity and Access Management in the Modern Enterprise
Navigating Identity and Access Management in the Modern EnterpriseNavigating Identity and Access Management in the Modern Enterprise
Navigating Identity and Access Management in the Modern Enterprise
 
Quantum Leap in Next-Generation Computing
Quantum Leap in Next-Generation ComputingQuantum Leap in Next-Generation Computing
Quantum Leap in Next-Generation Computing
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital Adaptability
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontology
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
AI in Action: Real World Use Cases by Anitaraj
AI in Action: Real World Use Cases by AnitarajAI in Action: Real World Use Cases by Anitaraj
AI in Action: Real World Use Cases by Anitaraj
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 

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