SlideShare ist ein Scribd-Unternehmen logo
1 von 11
Downloaden Sie, um offline zu lesen
JAVA QUESTIONS 1
1.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};
Answer: Option D
2.Which is a reserved word in the Java programming language?
A. method
B. native
C. subclasses
D. reference
E. array
Answer: Option B
3.Which is a valid keyword in java?
A. interface
B. string
C. Float
D. unsigned
Answer: Option A
4.What will be the output of the program?
class PassS
{
public static void main(String [] args)
{
PassS p = new PassS();
p.start();
}
void start()
{
String s1 = "slip";
String s2 = fix(s1);
System.out.println(s1 + " " + s2);
}
String fix(String s1)
{
s1 = s1 + "stream";
System.out.print(s1 + " ");
return "stream";
}
}
A. slip stream
B. slipstream stream
C. stream slip stream
D. slipstream slip stream
Answer: Option D
5.What will be the output of the program?
public class X
{
public static void main(String [] args)
{
try
{
badMethod();
System.out.print("A");
}
catch (RuntimeException ex) /* Line 10 */
{
System.out.print("B");
}
catch (Exception ex1)
{
System.out.print("C");
}
finally
{
System.out.print("D");
}
System.out.print("E");
}
public static void badMethod()
{
throw new RuntimeException();
}
}
A. BD
B. BCD
C. BDE
D. BCDE
Answer: Option C
6.Which is true about a method-local inner class?
A. It must be marked final.
B. It can be marked abstract.
C. It can be marked public.
D. It can be marked static.
Answer: Option B
7.Which statement is true about a static nested class?
A. You must have a reference to an instance of the enclosing class in order to instantiate it.
B. It does not have access to nonstatic members of the enclosing class.
C. It's variables and methods must be static.
D. It must extend the enclosing class.
Answer: Option B
8.
class Bar { }
class Test
{
Bar doBar()
{
Bar b = new Bar(); /* Line 6 */
return b; /* Line 7 */
}
public static void main (String args[])
{
Test t = new Test(); /* Line 11 */
Bar newBar = t.doBar(); /* Line 12 */
System.out.println("newBar");
newBar = new Bar(); /* Line 14 */
System.out.println("finishing"); /* Line 15 */
}
}
At what point is the Bar object, created on line 6, eligible for garbage collection?
A. after line 12
B. after line 14
C. after line 7, when doBar() completes
D. after line 15, when main() completes
Answer: Option B
9.Which of the following are valid calls to Math.max?
1. Math.max(1,4)
2. Math.max(2.3, 5)
3. Math.max(1, 3, 5, 7)
4. Math.max(-1.5, -2.8f)
A. 1, 2 and 4
B. 2, 3 and 4
C. 1, 2 and 3
D. 3 and 4
Answer: Option A
10.
public class Myfile
{
public static void main (String[] args)
{
String biz = args[1];
String baz = args[2];
String rip = args[3];
System.out.println("Arg is " + rip);
}
}
Select how you would start the program to cause it to print: Arg is 2
A. java Myfile 222
B. java Myfile 1 2 2 3 4
C. java Myfile 1 3 2 2
D. java Myfile 0 1 2 3
Answer: Option C
11.Which statement is true given the following?
Double d = Math.random();
A. 0.0 < d <= 1.0
B. 0.0 <= d < 1.0
C. Compilation fail
D. Cannot say.
Answer: Option B
12.Which two statements are true about wrapper or String classes?
1. If x and y refer to instances of different wrapper classes, then the
fragment x.equals(y) will cause a compiler failure.
2. If x and y refer to instances of different wrapper classes, then x == y can sometimes be
true.
3. If x and y are String references and if x.equals(y) is true, then x == y is true.
4. If x, y, and z refer to instances of wrapper classes and x.equals(y) is true,
and y.equals(z) is true, then z.equals(x) will always be true.
5. If x and y are String references and x == y is true, then y.equals(x) will be true.
A. 1 and 2
B. 2 and 3
C. 3 and 4
D. 4 and 5
Answer: Option D
13.
interface Base
{
boolean m1 ();
byte m2(short s);
}
which two code fragments will compile?
1. interface Base2 implements Base {}
2. abstract class Class2 extends Base
{ public boolean m1(){ return true; }}
3. abstract class Class2 implements Base {}
4. abstract class Class2 implements Base
{ public boolean m1(){ return (7 > 4); }}
5. abstract class Class2 implements Base
{ protected boolean m1(){ return (5 > 7) }}
A. 1 and 2
B. 2 and 3
C. 3 and 4
D. 1 and 5
Answer: Option C
14.
public class Test { }
What is the prototype of the default constructor?
A. Test( )
B. Test(void)
C. public Test( )
D. public Test(void)
Answer: Option C
15.
public void test(int x)
{
int odd = 1;
if(odd) /* Line 4 */
{
System.out.println("odd");
}
else
{
System.out.println("even");
}
}
Which statement is true?
A. Compilation fails.
B. "odd" will always be output.
C. "even" will always be output.
D. "odd" will be output for odd values of x, and "even" for even values.
Answer: Option A
16.
public class While
{
public void loop()
{
int x= 0;
while ( 1 ) /* Line 6 */
{
System.out.print("x plus one is " + (x + 1)); /* Line 8 */
}
}
}
Which statement is true?
A. There is a syntax error on line 1.
B. There are syntax errors on lines 1 and 6.
C. There are syntax errors on lines 1, 6, and 8.
D. There is a syntax error on line 6.
Answer: Option D
17.What will be the output of the program?
public class Test
{
public static void main (String[] args)
{
String foo = args[1];
String bar = args[2];
String baz = args[3];
System.out.println("baz = " + baz); /* Line 8 */
}
}
And the command line invocation:
> java Test red green blue
A. baz =
B. baz = null
C. baz = blue
D. Runtime Exception
Answer: Option D
18.Which statement is true?
A. A static method cannot be synchronized.
B. If a class has synchronized code, multiple threads can still access the nonsynchronized code.
C.
Variables can be protected from concurrent access problems by marking them with
the synchronized keyword.
D. When a thread sleeps, it releases its locks.
Answer: Option B
19.Which two can be used to create a new Thread?
1. Extend java.lang.Thread and override the run() method.
2. Extend java.lang.Runnable and override the start() method.
3. Implement java.lang.Thread and implement the run() method.
4. Implement java.lang.Runnable and implement the run() method.
5. Implement java.lang.Thread and implement the start() method.
A. 1 and 2
B. 2 and 3
C. 1 and 4
D. 3 and 4
Answer: Option C
20.What will be the output of the program (when you run with the -ea option) ?
public class Test
{
public static void main(String[] args)
{
int x = 0;
assert (x > 0) : "assertion failed"; /* Line 6 */
System.out.println("finished");
}
}
A. finished
B. Compilation fails.
C. An Assertion Error is thrown.
D. An Assertion Error is thrown and finished is output.
Answer: Option C
21.
public Object m()
{
Object o = new Float(3.14F);
Object [] oa = new Object[l];
oa[0] = o; /* Line 5 */
o = null; /* Line 6 */
oa[0] = null; /* Line 7 */
return o; /* Line 8 */
}
When is the Float object, created in line 3, eligible for garbage collection?
A. just after line 5
B. just after line 6
C. just after line 7
D. just after line 8
Answer: Option C
22.
class X2
{
public X2 x;
public static void main(String [] args)
{
X2 x2 = new X2(); /* Line 6 */
X2 x3 = new X2(); /* Line 7 */
x2.x = x3;
x3.x = x2;
x2 = new X2();
x3 = x2; /* Line 11 */
doComplexStuff();
}
}
after line 11 runs, how many objects are eligible for garbage collection?
A. 0
B. 1
C. 2
D. 3
Answer: Option C
23.
Which of the following are legal lines of code?
1. int w = (int)888.8;
2. byte x = (byte)1000L;
3. long y = (byte)100;
4. byte z = (byte)100L;
A. 1 and 2
B. 2 and 3
C. 3 and 4
D. All statements are correct.
Answer: Option D
24.Which two statements are equivalent?
1. 16*4
2. 16>>2
3. 16/2^2
4. 16>>>2
A. 1 and 2
B. 2 and 4
C. 3 and 4
D. 1 and 3
Answer: Option B
25.What will be the output of the program?
public class Switch2
{
final static short x = 2;
public static int y = 0;
public static void main(String [] args)
{
for (int z=0; z < 3; z++)
{
switch (z)
{
case x: System.out.print("0 ");
case x-1: System.out.print("1 ");
case x-2: System.out.print("2 ");
}
}
}
}
A. 0 1 2
B. 0 1 2 1 2 2
C. 2 1 0 1 0 0
D. 2 1 2 0 1 2
Answer: Option D
What will be the output of the program?
public class If2
{
static boolean b1, b2;
public static void main(String [] args)
{
int x = 0;
if ( !b1 ) /* Line 7 */
{
if ( !b2 ) /* Line 9 */
{
b1 = true;
x++;
if ( 5 > 6 )
{
x++;
}
if ( !b1 )
x = x + 10;
else if ( b2 = true ) /* Line 19 */
x = x + 100;
else if ( b1 | b2 ) /* Line 21 */
x = x + 1000;
}
}
System.out.println(x);
}
}
A. 0
B. 1
C. 101
D. 111
Answer: Option C

Weitere ähnliche Inhalte

Was ist angesagt?

14. Java defining classes
14. Java defining classes14. Java defining classes
14. Java defining classesIntro C# Book
 
02. Data Types and variables
02. Data Types and variables02. Data Types and variables
02. Data Types and variablesIntro C# Book
 
20.1 Java working with abstraction
20.1 Java working with abstraction20.1 Java working with abstraction
20.1 Java working with abstractionIntro C# Book
 
Technical aptitude Test 1 CSE
Technical aptitude Test 1 CSETechnical aptitude Test 1 CSE
Technical aptitude Test 1 CSESujata Regoti
 
19. Data Structures and Algorithm Complexity
19. Data Structures and Algorithm Complexity19. Data Structures and Algorithm Complexity
19. Data Structures and Algorithm ComplexityIntro C# Book
 
05. Java Loops Methods and Classes
05. Java Loops Methods and Classes05. Java Loops Methods and Classes
05. Java Loops Methods and ClassesIntro C# Book
 
Java apptitude-questions-part-1
Java apptitude-questions-part-1Java apptitude-questions-part-1
Java apptitude-questions-part-1vishvavidya
 
20.3 Java encapsulation
20.3 Java encapsulation20.3 Java encapsulation
20.3 Java encapsulationIntro C# Book
 
12. Java Exceptions and error handling
12. Java Exceptions and error handling12. Java Exceptions and error handling
12. Java Exceptions and error handlingIntro C# Book
 
Java basic tutorial by sanjeevini india
Java basic tutorial by sanjeevini indiaJava basic tutorial by sanjeevini india
Java basic tutorial by sanjeevini indiaSanjeev Tripathi
 
Chapter 4:Object-Oriented Basic Concepts
Chapter 4:Object-Oriented Basic ConceptsChapter 4:Object-Oriented Basic Concepts
Chapter 4:Object-Oriented Basic ConceptsIt Academy
 
Chapter 7:Understanding Class Inheritance
Chapter 7:Understanding Class InheritanceChapter 7:Understanding Class Inheritance
Chapter 7:Understanding Class InheritanceIt Academy
 
C Programming Language
C Programming LanguageC Programming Language
C Programming LanguageRTS Tech
 
20.5 Java polymorphism
20.5 Java polymorphism 20.5 Java polymorphism
20.5 Java polymorphism Intro C# Book
 

Was ist angesagt? (18)

14. Java defining classes
14. Java defining classes14. Java defining classes
14. Java defining classes
 
02. Data Types and variables
02. Data Types and variables02. Data Types and variables
02. Data Types and variables
 
20.1 Java working with abstraction
20.1 Java working with abstraction20.1 Java working with abstraction
20.1 Java working with abstraction
 
09. Java Methods
09. Java Methods09. Java Methods
09. Java Methods
 
Technical aptitude Test 1 CSE
Technical aptitude Test 1 CSETechnical aptitude Test 1 CSE
Technical aptitude Test 1 CSE
 
Core java
Core javaCore java
Core java
 
19. Data Structures and Algorithm Complexity
19. Data Structures and Algorithm Complexity19. Data Structures and Algorithm Complexity
19. Data Structures and Algorithm Complexity
 
05. Java Loops Methods and Classes
05. Java Loops Methods and Classes05. Java Loops Methods and Classes
05. Java Loops Methods and Classes
 
Java apptitude-questions-part-1
Java apptitude-questions-part-1Java apptitude-questions-part-1
Java apptitude-questions-part-1
 
20.3 Java encapsulation
20.3 Java encapsulation20.3 Java encapsulation
20.3 Java encapsulation
 
12. Java Exceptions and error handling
12. Java Exceptions and error handling12. Java Exceptions and error handling
12. Java Exceptions and error handling
 
09. Methods
09. Methods09. Methods
09. Methods
 
Java basic tutorial by sanjeevini india
Java basic tutorial by sanjeevini indiaJava basic tutorial by sanjeevini india
Java basic tutorial by sanjeevini india
 
Chapter 4:Object-Oriented Basic Concepts
Chapter 4:Object-Oriented Basic ConceptsChapter 4:Object-Oriented Basic Concepts
Chapter 4:Object-Oriented Basic Concepts
 
CBSE Sample Paper IP
CBSE Sample Paper IPCBSE Sample Paper IP
CBSE Sample Paper IP
 
Chapter 7:Understanding Class Inheritance
Chapter 7:Understanding Class InheritanceChapter 7:Understanding Class Inheritance
Chapter 7:Understanding Class Inheritance
 
C Programming Language
C Programming LanguageC Programming Language
C Programming Language
 
20.5 Java polymorphism
20.5 Java polymorphism 20.5 Java polymorphism
20.5 Java polymorphism
 

Ähnlich wie JAVA INTERVIEW QUESTIONS

Java language fundamentals
Java language fundamentalsJava language fundamentals
Java language fundamentalsKapish Joshi
 
Indus Valley Partner aptitude questions and answers
Indus Valley Partner aptitude questions and answersIndus Valley Partner aptitude questions and answers
Indus Valley Partner aptitude questions and answersSushant Choudhary
 
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 professionalIsabella789
 
Technical aptitude test 2 CSE
Technical aptitude test 2 CSETechnical aptitude test 2 CSE
Technical aptitude test 2 CSESujata Regoti
 
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 Objetosguest22a621
 
Comp 328 final guide
Comp 328 final guideComp 328 final guide
Comp 328 final guidekrtioplal
 
Fnt software solutions placement paper
Fnt software solutions placement paperFnt software solutions placement paper
Fnt software solutions placement paperfntsofttech
 
important C questions and_answers praveensomesh
important C questions and_answers praveensomeshimportant C questions and_answers praveensomesh
important C questions and_answers praveensomeshpraveensomesh
 
Name _______________________________ Class time __________.docx
Name _______________________________    Class time __________.docxName _______________________________    Class time __________.docx
Name _______________________________ Class time __________.docxrosemarybdodson23141
 
Java Questions and Answers
Java Questions and AnswersJava Questions and Answers
Java Questions and AnswersRumman Ansari
 
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 .pdfmayorothenguyenhob69
 
2 object orientation-copy
2 object orientation-copy2 object orientation-copy
2 object orientation-copyJoel Campos
 
ExamName___________________________________MULTIPLE CH.docx
ExamName___________________________________MULTIPLE CH.docxExamName___________________________________MULTIPLE CH.docx
ExamName___________________________________MULTIPLE CH.docxgitagrimston
 

Ähnlich wie JAVA INTERVIEW QUESTIONS (20)

Java language fundamentals
Java language fundamentalsJava language fundamentals
Java language fundamentals
 
7
77
7
 
Java Inheritance
Java InheritanceJava Inheritance
Java Inheritance
 
Scjp6.0
Scjp6.0Scjp6.0
Scjp6.0
 
Indus Valley Partner aptitude questions and answers
Indus Valley Partner aptitude questions and answersIndus Valley Partner aptitude questions and answers
Indus Valley Partner aptitude questions and answers
 
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
 
Technical aptitude test 2 CSE
Technical aptitude test 2 CSETechnical aptitude test 2 CSE
Technical aptitude test 2 CSE
 
Questões de Certificação SCJP
Questões de Certificação SCJPQuestões de Certificação SCJP
Questões de Certificação SCJP
 
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
 
Comp 328 final guide
Comp 328 final guideComp 328 final guide
Comp 328 final guide
 
T1
T1T1
T1
 
Fnt software solutions placement paper
Fnt software solutions placement paperFnt software solutions placement paper
Fnt software solutions placement paper
 
important C questions and_answers praveensomesh
important C questions and_answers praveensomeshimportant C questions and_answers praveensomesh
important C questions and_answers praveensomesh
 
Name _______________________________ Class time __________.docx
Name _______________________________    Class time __________.docxName _______________________________    Class time __________.docx
Name _______________________________ Class time __________.docx
 
Java Questions and Answers
Java Questions and AnswersJava Questions and Answers
Java Questions and Answers
 
Technical questions
Technical questionsTechnical questions
Technical questions
 
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
 
2 object orientation-copy
2 object orientation-copy2 object orientation-copy
2 object orientation-copy
 
ExamName___________________________________MULTIPLE CH.docx
ExamName___________________________________MULTIPLE CH.docxExamName___________________________________MULTIPLE CH.docx
ExamName___________________________________MULTIPLE CH.docx
 
Java Programming.pdf
Java Programming.pdfJava Programming.pdf
Java Programming.pdf
 

Mehr von zynofustechnology

JAVA QUESTIONS FOR INTERVIEW-3
JAVA QUESTIONS FOR INTERVIEW-3JAVA QUESTIONS FOR INTERVIEW-3
JAVA QUESTIONS FOR INTERVIEW-3zynofustechnology
 
PYTHON INTERVIEW QUESTIONS-4
PYTHON INTERVIEW QUESTIONS-4PYTHON INTERVIEW QUESTIONS-4
PYTHON INTERVIEW QUESTIONS-4zynofustechnology
 
PYTHON INTERVIEW QUESTIONS-2
PYTHON INTERVIEW QUESTIONS-2PYTHON INTERVIEW QUESTIONS-2
PYTHON INTERVIEW QUESTIONS-2zynofustechnology
 
Java Interview Questions - 1
Java Interview Questions - 1Java Interview Questions - 1
Java Interview Questions - 1zynofustechnology
 
SQL Interview Questions For Experienced
SQL Interview Questions For ExperiencedSQL Interview Questions For Experienced
SQL Interview Questions For Experiencedzynofustechnology
 
Software Testing Interview Questions For Experienced
Software Testing Interview Questions For ExperiencedSoftware Testing Interview Questions For Experienced
Software Testing Interview Questions For Experiencedzynofustechnology
 
Python Interview Questions For Experienced
Python Interview Questions For ExperiencedPython Interview Questions For Experienced
Python Interview Questions For Experiencedzynofustechnology
 
Python Interview Questions For Freshers
Python Interview Questions For FreshersPython Interview Questions For Freshers
Python Interview Questions For Fresherszynofustechnology
 
Java Interview Questions For Freshers
Java Interview Questions For FreshersJava Interview Questions For Freshers
Java Interview Questions For Fresherszynofustechnology
 
Digital marketing questions -3
Digital marketing questions -3Digital marketing questions -3
Digital marketing questions -3zynofustechnology
 
Digital marketing questions -2
Digital marketing questions -2Digital marketing questions -2
Digital marketing questions -2zynofustechnology
 
Digital marketing questions 1
Digital marketing questions  1Digital marketing questions  1
Digital marketing questions 1zynofustechnology
 

Mehr von zynofustechnology (16)

JAVA QUESTIONS -6
JAVA QUESTIONS -6JAVA QUESTIONS -6
JAVA QUESTIONS -6
 
JAVA QUESTIONS FOR INTERVIEW-3
JAVA QUESTIONS FOR INTERVIEW-3JAVA QUESTIONS FOR INTERVIEW-3
JAVA QUESTIONS FOR INTERVIEW-3
 
PYTHON INTERVIEW QUESTIONS-4
PYTHON INTERVIEW QUESTIONS-4PYTHON INTERVIEW QUESTIONS-4
PYTHON INTERVIEW QUESTIONS-4
 
PYTHON INTERVIEW QUESTIONS-2
PYTHON INTERVIEW QUESTIONS-2PYTHON INTERVIEW QUESTIONS-2
PYTHON INTERVIEW QUESTIONS-2
 
JAVA INTERVIEW QUESTIONS -3
JAVA INTERVIEW QUESTIONS -3JAVA INTERVIEW QUESTIONS -3
JAVA INTERVIEW QUESTIONS -3
 
Java Interview Questions-5
Java Interview Questions-5Java Interview Questions-5
Java Interview Questions-5
 
Java Interview Questions - 1
Java Interview Questions - 1Java Interview Questions - 1
Java Interview Questions - 1
 
SQL Interview Questions For Experienced
SQL Interview Questions For ExperiencedSQL Interview Questions For Experienced
SQL Interview Questions For Experienced
 
Software Testing Interview Questions For Experienced
Software Testing Interview Questions For ExperiencedSoftware Testing Interview Questions For Experienced
Software Testing Interview Questions For Experienced
 
Python Interview Questions For Experienced
Python Interview Questions For ExperiencedPython Interview Questions For Experienced
Python Interview Questions For Experienced
 
Python Interview Questions For Freshers
Python Interview Questions For FreshersPython Interview Questions For Freshers
Python Interview Questions For Freshers
 
Java Interview Questions For Freshers
Java Interview Questions For FreshersJava Interview Questions For Freshers
Java Interview Questions For Freshers
 
HR interview questions
HR interview questionsHR interview questions
HR interview questions
 
Digital marketing questions -3
Digital marketing questions -3Digital marketing questions -3
Digital marketing questions -3
 
Digital marketing questions -2
Digital marketing questions -2Digital marketing questions -2
Digital marketing questions -2
 
Digital marketing questions 1
Digital marketing questions  1Digital marketing questions  1
Digital marketing questions 1
 

Kürzlich hochgeladen

Cloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEECloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEEVICTOR MAESTRE RAMIREZ
 
Sending Calendar Invites on SES and Calendarsnack.pdf
Sending Calendar Invites on SES and Calendarsnack.pdfSending Calendar Invites on SES and Calendarsnack.pdf
Sending Calendar Invites on SES and Calendarsnack.pdf31events.com
 
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company OdishaBalasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odishasmiwainfosol
 
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...Angel Borroy López
 
Odoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 EnterpriseOdoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 Enterprisepreethippts
 
Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Andreas Granig
 
Comparing Linux OS Image Update Models - EOSS 2024.pdf
Comparing Linux OS Image Update Models - EOSS 2024.pdfComparing Linux OS Image Update Models - EOSS 2024.pdf
Comparing Linux OS Image Update Models - EOSS 2024.pdfDrew Moseley
 
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte GermanySuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte GermanyChristoph Pohl
 
A healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdfA healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdfMarharyta Nedzelska
 
UI5ers live - Custom Controls wrapping 3rd-party libs.pptx
UI5ers live - Custom Controls wrapping 3rd-party libs.pptxUI5ers live - Custom Controls wrapping 3rd-party libs.pptx
UI5ers live - Custom Controls wrapping 3rd-party libs.pptxAndreas Kunz
 
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...Cizo Technology Services
 
React Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaReact Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaHanief Utama
 
PREDICTING RIVER WATER QUALITY ppt presentation
PREDICTING  RIVER  WATER QUALITY  ppt presentationPREDICTING  RIVER  WATER QUALITY  ppt presentation
PREDICTING RIVER WATER QUALITY ppt presentationvaddepallysandeep122
 
Unveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New FeaturesUnveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New FeaturesŁukasz Chruściel
 
MYjobs Presentation Django-based project
MYjobs Presentation Django-based projectMYjobs Presentation Django-based project
MYjobs Presentation Django-based projectAnoyGreter
 
Folding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesFolding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesPhilip Schwarz
 
SpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at RuntimeSpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at Runtimeandrehoraa
 
What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...Technogeeks
 
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfGOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfAlina Yurenko
 
Post Quantum Cryptography – The Impact on Identity
Post Quantum Cryptography – The Impact on IdentityPost Quantum Cryptography – The Impact on Identity
Post Quantum Cryptography – The Impact on Identityteam-WIBU
 

Kürzlich hochgeladen (20)

Cloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEECloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEE
 
Sending Calendar Invites on SES and Calendarsnack.pdf
Sending Calendar Invites on SES and Calendarsnack.pdfSending Calendar Invites on SES and Calendarsnack.pdf
Sending Calendar Invites on SES and Calendarsnack.pdf
 
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company OdishaBalasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
 
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
 
Odoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 EnterpriseOdoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 Enterprise
 
Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024
 
Comparing Linux OS Image Update Models - EOSS 2024.pdf
Comparing Linux OS Image Update Models - EOSS 2024.pdfComparing Linux OS Image Update Models - EOSS 2024.pdf
Comparing Linux OS Image Update Models - EOSS 2024.pdf
 
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte GermanySuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
 
A healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdfA healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdf
 
UI5ers live - Custom Controls wrapping 3rd-party libs.pptx
UI5ers live - Custom Controls wrapping 3rd-party libs.pptxUI5ers live - Custom Controls wrapping 3rd-party libs.pptx
UI5ers live - Custom Controls wrapping 3rd-party libs.pptx
 
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
 
React Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaReact Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief Utama
 
PREDICTING RIVER WATER QUALITY ppt presentation
PREDICTING  RIVER  WATER QUALITY  ppt presentationPREDICTING  RIVER  WATER QUALITY  ppt presentation
PREDICTING RIVER WATER QUALITY ppt presentation
 
Unveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New FeaturesUnveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New Features
 
MYjobs Presentation Django-based project
MYjobs Presentation Django-based projectMYjobs Presentation Django-based project
MYjobs Presentation Django-based project
 
Folding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesFolding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a series
 
SpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at RuntimeSpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at Runtime
 
What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...
 
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfGOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
 
Post Quantum Cryptography – The Impact on Identity
Post Quantum Cryptography – The Impact on IdentityPost Quantum Cryptography – The Impact on Identity
Post Quantum Cryptography – The Impact on Identity
 

JAVA INTERVIEW QUESTIONS

  • 1. JAVA QUESTIONS 1 1.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}; Answer: Option D 2.Which is a reserved word in the Java programming language? A. method B. native C. subclasses D. reference E. array Answer: Option B 3.Which is a valid keyword in java? A. interface B. string C. Float D. unsigned Answer: Option A 4.What will be the output of the program? class PassS { public static void main(String [] args) { PassS p = new PassS(); p.start(); } void start() { String s1 = "slip"; String s2 = fix(s1); System.out.println(s1 + " " + s2); } String fix(String s1) {
  • 2. s1 = s1 + "stream"; System.out.print(s1 + " "); return "stream"; } } A. slip stream B. slipstream stream C. stream slip stream D. slipstream slip stream Answer: Option D 5.What will be the output of the program? public class X { public static void main(String [] args) { try { badMethod(); System.out.print("A"); } catch (RuntimeException ex) /* Line 10 */ { System.out.print("B"); } catch (Exception ex1) { System.out.print("C"); } finally { System.out.print("D"); } System.out.print("E"); } public static void badMethod() { throw new RuntimeException(); } } A. BD B. BCD C. BDE D. BCDE Answer: Option C
  • 3. 6.Which is true about a method-local inner class? A. It must be marked final. B. It can be marked abstract. C. It can be marked public. D. It can be marked static. Answer: Option B 7.Which statement is true about a static nested class? A. You must have a reference to an instance of the enclosing class in order to instantiate it. B. It does not have access to nonstatic members of the enclosing class. C. It's variables and methods must be static. D. It must extend the enclosing class. Answer: Option B 8. class Bar { } class Test { Bar doBar() { Bar b = new Bar(); /* Line 6 */ return b; /* Line 7 */ } public static void main (String args[]) { Test t = new Test(); /* Line 11 */ Bar newBar = t.doBar(); /* Line 12 */ System.out.println("newBar"); newBar = new Bar(); /* Line 14 */ System.out.println("finishing"); /* Line 15 */ } } At what point is the Bar object, created on line 6, eligible for garbage collection? A. after line 12 B. after line 14 C. after line 7, when doBar() completes D. after line 15, when main() completes Answer: Option B 9.Which of the following are valid calls to Math.max?
  • 4. 1. Math.max(1,4) 2. Math.max(2.3, 5) 3. Math.max(1, 3, 5, 7) 4. Math.max(-1.5, -2.8f) A. 1, 2 and 4 B. 2, 3 and 4 C. 1, 2 and 3 D. 3 and 4 Answer: Option A 10. public class Myfile { public static void main (String[] args) { String biz = args[1]; String baz = args[2]; String rip = args[3]; System.out.println("Arg is " + rip); } } Select how you would start the program to cause it to print: Arg is 2 A. java Myfile 222 B. java Myfile 1 2 2 3 4 C. java Myfile 1 3 2 2 D. java Myfile 0 1 2 3 Answer: Option C 11.Which statement is true given the following? Double d = Math.random(); A. 0.0 < d <= 1.0 B. 0.0 <= d < 1.0 C. Compilation fail D. Cannot say. Answer: Option B 12.Which two statements are true about wrapper or String classes? 1. If x and y refer to instances of different wrapper classes, then the
  • 5. fragment x.equals(y) will cause a compiler failure. 2. If x and y refer to instances of different wrapper classes, then x == y can sometimes be true. 3. If x and y are String references and if x.equals(y) is true, then x == y is true. 4. If x, y, and z refer to instances of wrapper classes and x.equals(y) is true, and y.equals(z) is true, then z.equals(x) will always be true. 5. If x and y are String references and x == y is true, then y.equals(x) will be true. A. 1 and 2 B. 2 and 3 C. 3 and 4 D. 4 and 5 Answer: Option D 13. interface Base { boolean m1 (); byte m2(short s); } which two code fragments will compile? 1. interface Base2 implements Base {} 2. abstract class Class2 extends Base { public boolean m1(){ return true; }} 3. abstract class Class2 implements Base {} 4. abstract class Class2 implements Base { public boolean m1(){ return (7 > 4); }} 5. abstract class Class2 implements Base { protected boolean m1(){ return (5 > 7) }} A. 1 and 2 B. 2 and 3 C. 3 and 4 D. 1 and 5 Answer: Option C 14. public class Test { } What is the prototype of the default constructor? A. Test( ) B. Test(void)
  • 6. C. public Test( ) D. public Test(void) Answer: Option C 15. public void test(int x) { int odd = 1; if(odd) /* Line 4 */ { System.out.println("odd"); } else { System.out.println("even"); } } Which statement is true? A. Compilation fails. B. "odd" will always be output. C. "even" will always be output. D. "odd" will be output for odd values of x, and "even" for even values. Answer: Option A 16. public class While { public void loop() { int x= 0; while ( 1 ) /* Line 6 */ { System.out.print("x plus one is " + (x + 1)); /* Line 8 */ } } } Which statement is true? A. There is a syntax error on line 1. B. There are syntax errors on lines 1 and 6. C. There are syntax errors on lines 1, 6, and 8. D. There is a syntax error on line 6. Answer: Option D
  • 7. 17.What will be the output of the program? public class Test { public static void main (String[] args) { String foo = args[1]; String bar = args[2]; String baz = args[3]; System.out.println("baz = " + baz); /* Line 8 */ } } And the command line invocation: > java Test red green blue A. baz = B. baz = null C. baz = blue D. Runtime Exception Answer: Option D 18.Which statement is true? A. A static method cannot be synchronized. B. If a class has synchronized code, multiple threads can still access the nonsynchronized code. C. Variables can be protected from concurrent access problems by marking them with the synchronized keyword. D. When a thread sleeps, it releases its locks. Answer: Option B 19.Which two can be used to create a new Thread? 1. Extend java.lang.Thread and override the run() method. 2. Extend java.lang.Runnable and override the start() method. 3. Implement java.lang.Thread and implement the run() method. 4. Implement java.lang.Runnable and implement the run() method. 5. Implement java.lang.Thread and implement the start() method. A. 1 and 2 B. 2 and 3 C. 1 and 4 D. 3 and 4 Answer: Option C
  • 8. 20.What will be the output of the program (when you run with the -ea option) ? public class Test { public static void main(String[] args) { int x = 0; assert (x > 0) : "assertion failed"; /* Line 6 */ System.out.println("finished"); } } A. finished B. Compilation fails. C. An Assertion Error is thrown. D. An Assertion Error is thrown and finished is output. Answer: Option C 21. public Object m() { Object o = new Float(3.14F); Object [] oa = new Object[l]; oa[0] = o; /* Line 5 */ o = null; /* Line 6 */ oa[0] = null; /* Line 7 */ return o; /* Line 8 */ } When is the Float object, created in line 3, eligible for garbage collection? A. just after line 5 B. just after line 6 C. just after line 7 D. just after line 8 Answer: Option C 22. class X2 { public X2 x; public static void main(String [] args) { X2 x2 = new X2(); /* Line 6 */ X2 x3 = new X2(); /* Line 7 */ x2.x = x3; x3.x = x2;
  • 9. x2 = new X2(); x3 = x2; /* Line 11 */ doComplexStuff(); } } after line 11 runs, how many objects are eligible for garbage collection? A. 0 B. 1 C. 2 D. 3 Answer: Option C 23. Which of the following are legal lines of code? 1. int w = (int)888.8; 2. byte x = (byte)1000L; 3. long y = (byte)100; 4. byte z = (byte)100L; A. 1 and 2 B. 2 and 3 C. 3 and 4 D. All statements are correct. Answer: Option D 24.Which two statements are equivalent? 1. 16*4 2. 16>>2 3. 16/2^2 4. 16>>>2 A. 1 and 2 B. 2 and 4 C. 3 and 4 D. 1 and 3 Answer: Option B 25.What will be the output of the program?
  • 10. public class Switch2 { final static short x = 2; public static int y = 0; public static void main(String [] args) { for (int z=0; z < 3; z++) { switch (z) { case x: System.out.print("0 "); case x-1: System.out.print("1 "); case x-2: System.out.print("2 "); } } } } A. 0 1 2 B. 0 1 2 1 2 2 C. 2 1 0 1 0 0 D. 2 1 2 0 1 2 Answer: Option D What will be the output of the program? public class If2 { static boolean b1, b2; public static void main(String [] args) { int x = 0; if ( !b1 ) /* Line 7 */ { if ( !b2 ) /* Line 9 */ { b1 = true; x++; if ( 5 > 6 ) { x++; } if ( !b1 ) x = x + 10; else if ( b2 = true ) /* Line 19 */ x = x + 100; else if ( b1 | b2 ) /* Line 21 */ x = x + 1000; } } System.out.println(x); } }
  • 11. A. 0 B. 1 C. 101 D. 111 Answer: Option C