1Z0-803 Exam Questions
266 real 1Z0-803 exam questions with expert-verified answers and explanations. Page 6 of 6.
- Question #256Using Loop Constructs
Given: public class Natural { private int i; void disp() { while (i <= 5) { for (int i=1; i <=5;) { System.out.print(i + " "); i++; } i++; } } public static void main(String[] args...
loop constructsnested loopsvariable scopevariable shadowing - Question #257Using Loop Constructs
Given: public class Test { static boolean bVar; public static void main(String[] args) { boolean bVar1 = true; int count =8; do { System.out.println("Hello Java! " +count); if (cou...
do-while loopcontrol flowstatic variablesboolean logic - Question #258Using Operators and Decision Constructs
Given the code fragment: System.out.println(2 + 4 * 9 - 3); //Line 21 System.out.println((2 + 4) * 9 - 3); // Line 22 System.out.println(2 + (4 * 9) - 3); // Line 23 System.out.pri...
operatorsoperator precedencearithmetic operationsparentheses - Question #259Working with Inheritance
Given: class Base { public static void main(String[] args) { System.out.println("Base " + args[2]); } } public class Sub extends Base{ public static void main(String[] args) { Syst...
static methodsmethod hidingcommand-line argumentsJVM execution - Question #260Working with Inheritance
Given: interface Pet { } class Dog implements Pet { } public class Beagle extends Dog{ } Which three are valid?
polymorphisminheritanceinterfacestype compatibility - Question #261Creating and Using Arrays
Given the code fragment: // insert code here arr[0] = new int[3]; arr[0][0] = 1; arr[0][1] = 2; arr[0][2] = 3; arr[1] = new int[4]; arr[1][0] = 10; arr[1][1] = 20; arr[1][2] = 30;...
arraysmulti-dimensional arraysjagged arraysarray initialization - Question #262Handling Exceptions
Given: public class Test { public static void main(String[] args) { int ax = 10, az = 30; int aw = 1, ay = 1; try { aw = ax % 2; ay = az / aw; } catch (ArithmeticException e1) { Sy...
exception handlingtry-catchArithmeticExceptioncontrol flowunhandled exceptions - Question #263Using Loop Constructs
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; } Wh...
Nested loopsLoop control statementsfor loopcontinue keyword - Question #264Working with Methods and Encapsulation
Given the code fragment: class Student { int rollnumber; String name; List cources = new ArrayList(); // insert code here public String toString() { return rollnumber + " : " + nam...
ConstructorsMethod signaturesAccess modifiersArrayList - Question #265Using Loop Constructs
Given the code fragment: public class ForTest { public static void main(String[] args) { int[] array = {1, 2, 3}; for ( foo ) { } } Which three code fragments, when replaced indivi...
For loop syntaxEnhanced for loopLoop constructs - Question #266Working with Inheritance
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()...
InheritancePolymorphismAbstract classesMethod overriding - Question #267Handling Exceptions
Which two statements correctly describe checked exception?
Checked exceptionsException hierarchyException types - Question #268Java Basics
Given: public class ColorTest { public static void main(String[] args) { String[] colors = {"red", "blue","green","yellow","maroon","cyan"}; int count = 0; for (String c : colors)...
Array initializationCompilation errorString arrays - Question #269Java Basics
Given: public class App { // Insert code here System.out.print("Welcome to the world of Java"); } } Which two code fragments, when inserted independently at line // Insert code her...
Main methodMethod signaturesJava entry point - Question #270Using Loop Constructs
Given the code fragment: public class Test { public static void main(String[] args) { boolean isChecked = false; int arry[] = {1,3,5,7,8,9}; int index = arry.length; while ( <code1...
While loopArray indexingLoop controlConditional logic - Question #271Using Loop Constructs
Given: public class TestLoop { public static void main(String[] args) { int array[] = {0, 1, 2, 3, 4}; int key = 3; for (int pos = 0; pos < array.length; ++pos) { if (array[pos] ==...
For loopVariable scopeCompilation errorLoop variables