1Z0-803 Exam Questions
266 real 1Z0-803 exam questions with expert-verified answers and explanations. Page 4 of 6.
- Question #152Using Loop Constructs
Given: What is the result?
loop syntaxcompilation error - Question #153Creating and Using Arrays
Given the code fragment: 5. // insert code here 6. 7. arr[0] = new int[3]; 8. arr[0][0] = 1; 9. arr[0][1] = 2; 10. arr[0][2] = 3; 11. 12. arr[1] = new int[4]; 13. arr[1][0] = 10; 1...
2D arraysjagged arraysarray initialization - Question #154Using Loop Constructs
Given the code fragment: 12. for (int row = 4; row > 0; row--) { 13. int col = row; 14. while (col <= 4) { 15. System.out.print(col); 16. col++; 17. } 18. System.out.println(); 19....
nested loopsfor loopwhile loop - Question #155Working with Java Data Types
Given: public class Test3 { public static void main(String[] args) { double[] array = {10, 20.23, 'c', 300.00f}; for (double d : array) { d = d + 10; System.out.print(d + " "); } }...
primitive type conversionsfor-each loopchar to double conversion - Question #157Java Basics
Given this code in a file Traveler.java: And the commands: javac Traveler.java java Traveler Java Duke What is the result?
main methodcommand line argumentsString[] args - Question #158Working with Inheritance
Given: What is the result?
polymorphismmethod overridinginheritance - Question #159Working with Inheritance
Which statement is true about the default constructor of a top-level class?
constructorsdefault constructorsuperclass constructor - Question #160Working with Selected Classes from the Java API
Given: What is the result?
String methodscharacter manipulationlooping - Question #161Working with Selected Classes from the Java API
Given: What is the result?
String methodsString concatenation - Question #162Using Operators and Decision Constructs
Given: public class VarScope { public static void main (Stirng[] args) { String color = "red"; int qty = 10; if (color.equals("red")) { // line n1 int amount = qty * 10; } else if...
variable scopeif-elsecompilation errorlocal variables - Question #163Java Basics
Given: Which line causes a compilation error?
compilation errorsyntax error - Question #164Using Loop Constructs
Given: public class Test { public static void main(String[] args) { int i = 1; do { if ( i % 2 == 0) continue; if (i == 5) break; System.out.print(i + "\t"); i++; } while (true); }...
do-while loopcontinue statementinfinite looploop tracing - Question #165Handling Exceptions
Which three statements are true regarding exception handling in Java?
exception handlingtry-catch-finallychecked vs unchecked exceptionscustom exceptions - Question #166Using Operators and Decision Constructs
Given: public class Test { public static void main (String[] args) { int i = 25; int j = i++ + 1; if (j % 5 == 0) { System.out.println(j + " is divisible by 5"); } else { System.ou...
operatorspost-incrementif-elsearithmetic operations - Question #167Working with Methods and Encapsulation
Given the code fragment: 1. class Test { 2. public static void main(String[] args) { 3. Test t = new Test(); 4. int[] arr = new int[10]; 5. arr = t.subArray(arr, 0, 2); 6. } 7. //...
method signaturemethod parametersreturn typearrays - Question #168Handling Exceptions
An unchecked exception occurs in a method doSomething(). Must other code be added in the doSomething() method for it to compile and run successfully?
unchecked exceptionsexception handlingRuntimeException - Question #169Java Basics
Given: package handy.dandy; public class Keystroke { public void typeExclamation() { System.out.println("!"); } } And 1. package handy; 2. public class Greet { 3. public static voi...
packagesimport statementfully qualified namecompilation error - Question #170Working with Methods and Encapsulation
The protected modifier on a Field declaration within a public class means that the field ______________.
access modifiersprotectedinheritancepackages - Question #171Java Basics
Given: What is the result?
compilation errorsyntax error - Question #172Java Basics
Given: What is the result?
variable manipulationoutput predictionarithmetic operations - Question #173Working with Inheritance
Given: Class A { } Class B { } Interface X { } Interface Y { } Which two definitions of class C are valid?
inheritanceinterfacesextends keywordimplements keyword - Question #174Handling Exceptions
View the exhibit. Given the code fragment: Which change enables the code to print the following? James age: 20 Williams age: 32
checked exceptionsthrows keywordexception handling - Question #175Handling Exceptions
Given: What is the result?
exception handlingtry-catch blockoutput prediction - Question #176Working with Methods and Encapsulation
Given the code format: Which code fragment must be inserted at line 6 to enable the code to compile?
object creationmethod return typecompilation - Question #178Using Loop Constructs
Given: What is the result?
loopingconditional logicoutput prediction - Question #179Using Loop Constructs
Given: What is the result?
loopingoutput predictionarray iteration - Question #180Java Basics
Given: What is the result?
variable manipulationoutput predictionarithmetic operations - Question #181Working with Selected Classes from the Java API
Given: What is the result?
array indexingString methodsArrayIndexOutOfBoundsException - Question #182Working with Java Data Types
Given: What is the result?
variable scopeoutput predictionoperatorsdata types - Question #183Using Operators and Decision Constructs
Given the code fragment: What is the result?
operatorsexpressionsdata types - Question #184Working with Selected Classes from the Java API
Given: What is the result?
String methodsruntime exceptionStringIndexOutOfBoundsException - Question #185Creating and Using Arrays
Which two statements are true for a two-dimensional array of primitive data type?
multidimensional arraysarray propertiesObject class - Question #186Handling Exceptions
Given: What is the result?
runtime exceptionnull pointerarray access - Question #187Working with Selected Classes from the Java API
Given: What is the result?
String methodsstring manipulation - Question #188Working with Inheritance
Given: Which two classes use the shape class correctly?
inheritanceabstract classesmethod overridingpolymorphism - Question #189Working with Inheritance
Given the class definitions: And the code fragment of the main() method, What is the result?
inheritancemethod overridingpolymorphismconstructors - Question #190Using Operators and Decision Constructs
Given: What is the result?
operatorsdecision constructsconditional statementscontrol flow - Question #191Java Basics
Which two items can legally be contained within a java class declaration?
class structuresyntaxfieldsmethods - Question #192Working with Selected Classes from the Java API
Given: What is the result?
String methodsruntime exceptionStringIndexOutOfBoundsException - Question #193Working with Inheritance
Given the code fragments: What is the result?
inheritancemethod overridingpolymorphismcompilation errors - Question #194Working with Selected Classes from the Java API
Given: public class MyClass { public static void main(String[] args) { String s = " Java Duke "; int len = s.trim().length(); System.out.print(len); } } What is the result?
String methodstrim()length() - Question #195Working with Selected Classes from the Java API
Given the code fragment: What is the result?
ArrayListcollectionsarray manipulation - Question #196Working with Methods and Encapsulation
Which two actions will improve the encapsulation of a class?
encapsulationaccess modifiersdefensive copying - Question #197Working with Methods and Encapsulation
Given: The class is poorly encapsulated. You need to change the circle class to compute and return the area instead. Which two modifications are necessary to ensure that the class...
encapsulationrefactoringaccess modifiersmethods - Question #198Using Loop Constructs
Given: What is the result?
control flowloopsdecision constructsarray processing - Question #199Using Operators and Decision Constructs
Given: Which code fragment, when inserted at line 7, enables the code print true?
conditional logicoperatorsString comparison - Question #200Using Operators and Decision Constructs
Given the code fragment: What is the result if the integer aVar is 9?
conditional statementsif-elseoperatorsvariable manipulation - Question #201Creating and Using Arrays
Given: And the commands: Javac Test.java Java Test 12345 What is the result?
command-line argumentsmain methodarray accessArrayIndexOutOfBoundsException - Question #202Working with Methods and Encapsulation
Given the code fragment: Which code fragment, when inserted at // insert code here, enables the code to compile and and print a b c?
method signaturesstatic methodsreturn typesList interface - Question #203Using Operators and Decision Constructs
Given: What is the result?
increment operatorsvariable stateoperator precedence