Q1. View AnswerAnswer: Q2. View AnswerAnswer: Q3. View AnswerAnswer: Q4. View AnswerAnswer: Q5. View AnswerAnswer: Q6. View AnswerAnswer: Q7. View AnswerAnswer: Q8. View AnswerAnswer: Q9. View AnswerAnswer: Q10. View AnswerAnswer: Q11. View AnswerAnswer: Q12. View AnswerAnswer: Q13. View AnswerAnswer: Q14. View AnswerAnswer: Q15. View AnswerAnswer:
Q1. View AnswerAnswer: Q2. View AnswerAnswer: Q3. View AnswerAnswer: Q4. View AnswerAnswer: Q5. View AnswerAnswer: Q6. View AnswerAnswer: Q7. View AnswerAnswer: Q8. View AnswerAnswer: Q9. View AnswerAnswer: Q10. View AnswerAnswer: Q11. View AnswerAnswer: Q12. View AnswerAnswer: Q13. View AnswerAnswer: Q14. View AnswerAnswer: Q15. View AnswerAnswer:
Q1. View AnswerAnswer: Q2. View AnswerAnswer: Q3. View AnswerAnswer: Q4. View AnswerAnswer: Q5. View AnswerAnswer: Q6. View AnswerAnswer: Q7. View AnswerAnswer: Q8. View AnswerAnswer: Q9. View AnswerAnswer: Q10. View AnswerAnswer: Q11. View AnswerAnswer: Q12. View AnswerAnswer: Q13. View AnswerAnswer: Q14. View AnswerAnswer: Q15. View AnswerAnswer:
Q1. View AnswerAnswer: Q2. View AnswerAnswer: Q3. View AnswerAnswer: Q4. View AnswerAnswer: Q5. View AnswerAnswer: Q6. View AnswerAnswer: Q7. View AnswerAnswer: Q8. View AnswerAnswer: Q9. View AnswerAnswer: Q10. View AnswerAnswer: Q11. View AnswerAnswer: Q12. View AnswerAnswer: Q13. View AnswerAnswer: Q14. View AnswerAnswer: Q15. View AnswerAnswer:
Q1. View AnswerAnswer: Q2. View AnswerAnswer: Q3. View AnswerAnswer: Q4. View AnswerAnswer: Q5. View AnswerAnswer: Q6. View AnswerAnswer: Q7. View AnswerAnswer: Q8. View AnswerAnswer: Q9. View AnswerAnswer: Q10. View AnswerAnswer: Q11. View AnswerAnswer: Q12. View AnswerAnswer: Q13. View AnswerAnswer: Q14. View AnswerAnswer: Q15. View AnswerAnswer:
Q1. View AnswerAnswer: Q2. View AnswerAnswer: Q3. View AnswerAnswer: Q4. View AnswerAnswer: Q5. View AnswerAnswer: Q6. View AnswerAnswer: Q7. View AnswerAnswer: Q8. View AnswerAnswer: Q9. View AnswerAnswer: Q10. View AnswerAnswer: Q11. View AnswerAnswer: Q12. View AnswerAnswer: Q13. View AnswerAnswer: Q14. View AnswerAnswer: Q15. View AnswerAnswer:
Q1. View AnswerAnswer: Q2. View AnswerAnswer: Q3. View AnswerAnswer: Q4. View AnswerAnswer: Q5. View AnswerAnswer: Q6. View AnswerAnswer: Q7. View AnswerAnswer: Q8. View AnswerAnswer: Q9. View AnswerAnswer: Q10. View AnswerAnswer: Q11. View AnswerAnswer: Q12. View AnswerAnswer: Q13. View AnswerAnswer: Q14. View AnswerAnswer: Q15. View AnswerAnswer:
Q1. Given: What is the result? A. 10 20 30 40 B. 0 0 30 40 C. Compilation fails D. An exception is thrown at runtime View AnswerAnswer: A Q2. Given: What is the result? A. 10:20 B. 0:20 C. Compilation fails at line n1 D. Compilation fails at line n2 View AnswerAnswer: D Q3. Given the following classes: Which two options fail to compile when placed at line n1 of the main method? A. employee.salary…
Q1. Which statement is/are true? I. Default constructor only contains "super();" call. II. We can't use any access modifier with a constructor. III. A constructor should not have a return type. A. Only I. B. Only II. C. Only I and II. D. Only I and III. E. AIL View AnswerAnswer: D Explanation: Statement I is correct as the default constructor only contains super0 call Statement II is incorrect as we can…
Q1. Given: What is the result? A. Option A B. Option B C. Option C D. Option D View AnswerAnswer: D Q2. Given the code fragment: What is the result? A. Sum is 600 B. Compilation fails at line n1. C. Compilation fails at line n2. D. A ClassCastException is thrown at line n1. E. A ClassCastException is thrown at line n2. View AnswerAnswer: C Q3. Given the following two classes: How should you write methods…
Q1. Given: A. ns = 50 S = 125 ns = 125 S = 125 ns = 100 S = 125 B. ns = 50 S = 125 ns = 125 S = 125 ns = 0 S = 125 C. ns = 50 S = 50 ns = 125 S = 125 ns = 100 S = 100 D. ns = 50 S…
Q1. Given: What is the result? A. 2 4 6 8 10 12 B. 2 4 6 8 10 12 14 C. Compilation fails D. The program prints multiple of 2 infinite times E. The program prints nothing View AnswerAnswer: B Q2. Which three statements are benefits of encapsulation? A. Allows a class implementation to change without changing t he clients B. Protects confidential data from leaking out of the…
Q1. Given the code fragment: What is the result? A. 1:2:3:4:5: B. 1:2:3: C. Compilation fails. D. An ArrayoutofBoundsException is thrown at runtime. View AnswerAnswer: A Q2. Given: What is the result? A. Good Day! Good Luck! B. Good Day! Good Day! C. Good Luck! Good Day! D. Good Luck! Good Luck! E. Compilation fails View AnswerAnswer: E Q3. Which of the following can fill in the blank in this code to make it compile?…
Q1. Give: What is the result? A. 1525 B. 13 C. Compilation fails D. An exception is thrown at runtime E. The program fails to execute due to runtime error View AnswerAnswer: D Q2. Given: abstract class A1 { public abstract void m1(); public void m2() { System.out.println("Green"); } } abstract class A2 extends A1 { public abstract void m3(); public void m1() { System.out.println("Cyan"); } public void m2() { System.out.println("Blue"); } } public class A3 extends A2…
Q1. Given the code fragment: for (int ii = 0; ii < 3;ii++) { int count = 0; for (int jj = 3; jj > 0; jj--) { if (ii == jj) { ++count; break; } } System.out.print(count); continue; } What is the result? A. 011 B. 012 C. 123 D. 000 View AnswerAnswer: A Q2. Which two items can legally be contained within a java class declaration? A. An import statement B. A field declaration C. A package…
Q1. Given: What is the result? A. 100 210 B. Compilation fails due to an error in line n1 C. Compilation fails due to an error at line n2 D. Compilation fails due to an error at line n3 View AnswerAnswer: C Q2. Given the code fragment: What is the result? A. Element 0 Element 1 B. Null element 0 Null element 1 C. Null Null D. A NullPointerException is thrown at…
Q1. Given: What would be the output, if it is executed as a program? A. name =, pass = B. name = null, pass = null C. name = null, pass = false D. name = null pass = true E. Compile error. View AnswerAnswer: C Explanation: Both name and pass variables are instance variables, and we haven't given them any values, so they take their default values. For…
Q1. Given: What is the result? A. true:true B. true:false C. false:true D. false:false View AnswerAnswer: C Q2. Given: What is the result? A. Option A B. Option B C. Option C D. Option D View AnswerAnswer: B Q3. Given: Which constructor initializes the variable x3? A. Only the default constructor of class X B. Only the no-argument constructor of class Y C. Only the no-argument constructor of class Z D. Only the default constructor of object class View AnswerAnswer:…
Q1. Given: public class TestOperator { public static void main(String[] args) { int result = 30 -12 / (2*5)+1; System.out.print("Result = " + result); } } What is the result? A. Result = 2 B. Result = 3 C. Result = 28 D. Result = 29 E. Result = 30 View AnswerAnswer: E Q2. Which three statements are true about the structure of a Java class? A. A class can have only one private constructor. B.…
Q1. Given the code fragment: class Student { int rollnumber; String name; List cources = new ArrayList(); // insert code here public String toString() { return rollnumber + " : " + name + " : " + cources; } } And, public class Test { public static void main(String[] args) { List cs = newArrayList(); cs.add("Java"); cs.add("C"); Student s = new Student(123,"Fred", cs); System.out.println(s); } } Which code fragment, when inserted at line // insert code here, enables class…
Q1. Given the code fragment: int b = 3; if ( !(b > 3)) { System.out.println("square "); }{ System.out.println("circle "); } System.out.println("..."); What is the result? A. square... B. circle... C. squarecircle... D. Compilation fails. View AnswerAnswer: C Q2. Given the code fragment: What is the result if the integer aVar is 9? A. 10 Hello world! B. 10 Hello universe! C. 9 Hello world! D. Compilation fails. View AnswerAnswer: A Q3. Given the following code for the classes MyException and…
Q1. Class StaticField { static int i = 7; public static void main(String[] args) { StaticFied obj = new StaticField(); obj.i++; StaticField.i++; obj.i++; System.out.println(StaticField.i + " "+ obj.i); } } What is the result? A. 10 10 B. 8 9 C. 9 8 D. 7 10 View AnswerAnswer: A Q2. Given: And the commands: Javac Test.java Java Test 12345 What is the result? A. Number us : 12345 B. A NullPointerException is thrown at runtime C. A NumberFormatException is thrown at runtime D. AnArrayIndexOutOfBoundException…
Q1. Given the code fragment: What could expression1 and expression2 be, respectively, in order to produce output –8, 16? A. + +a, - -b B. + +a, b- -C. A+ +, - - b D. A + +, b - -View AnswerAnswer: D Q2. Given the code fragment: What is the result? A. Element 0 Element 1 B. Null element 0 Null element 1 C. Null Null D. A NullPointerException…
Q1. Given the code fragment: public static void main(String[] args) { int iArray[] = {65, 68, 69}; iArray[2] = iArray[0]; iArray[0] = iArray[1]; iArray[1] = iArray[2]; for (int element : iArray) { System.out.print(element + " "); } A. 68, 65, 69 B. 68, 65, 65 C. 65, 68, 65 D. 65, 68, 69 E. Compilation fails View AnswerAnswer: B Q2. Given: What is the result? A. 200.0 : 100.0 B. 400.0 : 200.0 C. 400.0 : 100.0 D. Compilation fails. View…
Q1. public class ForTest { public static void main(String[] args) { int[] arrar = {1,2,3}; for ( foo ) { } } } Which three are valid replacements for foo so that the program will compiled and run? A. int i: array B. int i = 0; i < 1; i++ C. ;; D. ; i < 1; i++ E. ; i < 1; View AnswerAnswer: A,B,C Q2. Given: Which code fragment should you use…
Q1. Given the code fragment: What is the result? A. 2 4 B. 0 2 4 6 C. 0 2 4 D. Compilation fails View AnswerAnswer: C Q2. Given: public class Test { public static void main(String[] args) { int arr[] = new int[4]; arr[0] = 1; arr[1] = 2; arr[2] = 4; arr[3] = 5; int sum = 0; try { for (int pos = 0; pos
Q1. Given: What is the result? A. hEllOjAvA! B. Hello java! C. Out of limits hEllOjAvA! D. Out of limits View AnswerAnswer: C Q2. Given: public class Test { public static void main(String[] args) { int day = 1; switch (day) { case "7": System.out.print("Uranus"); case "6": System.out.print("Saturn"); case "1": System.out.print("Mercury"); case "2": System.out.print("Venus"); case "3": System.out.print("Earth"); case "4": System.out.print("Mars"); case "5": System.out.print("Jupiter"); } } } Which two modifications, made independently, enable the code to compile and run? A. Adding a break statement…
Q1. Given: What is the result? A. Base DerivedA B. Base DerivedB C. DerivedB DerivedB D. DerivedB DerivedA E. A classcast Except ion is thrown at runtime. View AnswerAnswer: C Q2. Given: What is the result? A. 100 210 B. Compilation fails due to an error in line n1 C. Compilation fails due to an error at line n2 D. Compilation fails due to an error at line n3 View AnswerAnswer: C Q3. Given: public class…
Q1. Given the code fragment: What is the result? A. Match 1 B. Match 2 C. No Match D. A NullPointerException is thrown at runtime. View AnswerAnswer: B Explanation: it will compare the string contents of the StringBuilder with string object. Q2. Given: What is the result? A. Red 0 Orange 0 Green 3 B. Red 0 Orange 0 Green 6 C. Red 0 Orange 1 D. Green 4 E. Compilation fails View AnswerAnswer: E Q3. Given the code fragment: Which option can…
Q1. Given: What is the output? A. [21, 13, 11] B. [30] C. [] D. Compilation fails due to error at line 7 E. Compilation tails due to error at line 10 View AnswerAnswer: D Explanation: Option D is the correct answer. Code fails to compile as we can't use primitive for collections type, so in this code trying to use int at line 7, causes a compile error. We should…
Q1. Given the code fragment: What is the result? A. 2 4 B. 0 2 4 6 C. 0 2 4 D. Compilation fails View AnswerAnswer: C Q2. Given: What is the result? A. 100 210 B. Compilation fails due to an error in line n1 C. Compilation fails due to an error at line n2 D. Compilation fails due to an error at line n3 View AnswerAnswer: C Q3. Given the code fragment: //…
Q1. Given the code fragment: Which option represents the state of the num array after successful completion of the outer loop? A. Option A B. Option B C. Option C D. Option D View AnswerAnswer: A Q2. Given: How many MarkList instances are created in memory at runtime? A. 1 B. 2 C. 3 D. 4 View AnswerAnswer: A Q3. Given: abstract class A1 { public abstract void m1(); public void m2() { System.out.println("Green"); } } abstract class A2…
Q1. Which statement is true about Java byte code? A. It can run on any platform. B. It can run on any platform only if it was compiled for that platform. C. It can run on any platform that has the Java Runtime Environment. D. It can run on any platform that has a Java compiler. E. It can run on any platform only if…
Q1. Given the code fragment: What is the result? A. Jesse 25 Walter 52 B. Compilation fails only at line n1 C. Compilation fails only at line n2 D. Compilation fails at both line n1 and line n2 View AnswerAnswer: D Q2. Given: How many objects have been created when the line / / do complex stuff is reached? A. Two B. Three C. Four D. Six View AnswerAnswer: C Q3. Given: What is the…
Q1. Given the code fragment: What could expression1 and expression2 be, respectively, in order to produce output –8, 16? A. + +a, - -b B. + +a, b- -C. A+ +, - - b D. A + +, b - -View AnswerAnswer: D Q2. Which usage represents a valid way of compiling java source file with the name "Main"? A. javac Main.java B. java Main.class C. java Main.java D.…
Q1. Given the code fragment: public static void main(String[] args) { int iArray[] = {65, 68, 69}; iArray[2] = iArray[0]; iArray[0] = iArray[1]; iArray[1] = iArray[2]; for (int element : iArray) { System.out.print(element + " "); } A. 68, 65, 69 B. 68, 65, 65 C. 65, 68, 65 D. 65, 68, 69 E. Compilation fails View AnswerAnswer: B Q2. Given the content of three files: Which statement is true? Which statement is true? A. Only the…