1Z0-803 Exam Questions
266 real 1Z0-803 exam questions with expert-verified answers and explanations. Page 5 of 6.
- Question #204Java Basics
Given: What will be the output?
output predictionbasic program execution - Question #205Using Operators and Decision Constructs
Given the code fragment: What could expression1 and expression2 be, respectively, in order to produce output -8, 16?
increment operatorsdecrement operatorsoperator precedence - Question #206Java Basics
Given: What is the result?
program executioncompilation errorsruntime errors - Question #207Java Basics
Given: And the commands: Javac Jump.java Java Jump crazy elephant is always What is the result?
command line argumentsmain methodString array - Question #208Creating and Using Arrays
Given: What is the result?
arraysarray indexingvariable assignment - Question #209Using Loop Constructs
Given: What is the result?
while loopinfinite looploop control - Question #210Working with Selected Classes from the Java API
Given: Which code fragment, when inserted at line 14, enables the code to print Mike Found?
ArrayListindexOf methodobject equalitycustom objects - Question #211Working with Java Data Types
Give: What is the result?
primitive typestype conversionstring concatenationoperators - Question #212Working with Java Data Types
Given: What is the result?
String comparisonobject equalityreference equality - Question #213Working with Inheritance
Given: Which constructor initializes the variable x3?
constructorsconstructor chaininginheritance - Question #214Java Basics
Given: How many objects have been created when the line / / do complex stuff is reached?
object creationString literalsautoboxing - Question #215Using Operators and Decision Constructs
Given: What is result?
conditional statementsprogram flow - Question #216Working with Java Data Types
Given the fragment: What is the result?
primitive typestype castingarithmetic operators - Question #217Working with Selected Classes from the Java API
Given: Which code fragment, when inserted at line 9, enables the code to print true?
String classobject referencesreference equality - Question #218Using Loop Constructs
Given the code fragment: What is the result?
for looploop iterationarithmetic operatorsruntime errors - Question #219Handling Exceptions
Given the classes: - AssertionError - ArithmeticException - ArrayIndexOutofBoundsException - FileNotFoundException - IllegalArgumentException - IOError - IOException - NumberFormat...
checked exceptionsunchecked exceptionsexception hierarchy - Question #220Working with Methods and Encapsulation
Given: public class Test1 { static void doubling (Integer ref, int pv) { ref =20; pv = 20; } public static void main(String[] args) { Integer iObj = new Integer(10); int iVar = 10;...
pass by valueInteger immutabilitymethod parametersautoboxing - Question #221Working with Inheritance
Given: class Mid { public int findMid(int n1, int n2) { return (n1 + n2) / 2; } } public class Calc extends Mid { public static void main(String[] args) { int n1 = 22, n2 = 2; // i...
inheritancemethod callingobject instantiationpolymorphism - Question #222Working with Selected Classes from the Java API
Given: import java.util.*; public class Ref { public static void main(String[] args) { StringBuilder s1 = new StringBuilder("Hello Java!"); String s2 = s1.toString(); List<String>...
getClass methodStringBuilderStringArrayListruntime type - Question #223Working with Methods and Encapsulation
Given: public class ComputeSum { public int x; public int y; public int sum; public ComputeSum (int nx, int ny) { x = nx; y =ny; updateSum(); } public void setX(int nx) { x = nx; u...
access modifiersencapsulationfieldsconstructors - Question #224Java Basics
Given the following four Java file definitions: // Foo.java package facades; public interface Foo { } // Boo.java package facades; public interface Boo extends Foo { } // Woofy.jav...
packagesimport statementsinterfaces - Question #225Working with Inheritance
Given: public class SuperTest { public static void main(String[] args) { statement1 statement2 statement3 } } class Shape { public Shape() { System.out.println("Shape: constructor"...
inheritanceconstructorssuper()method overridingmethod overloading - Question #226Java Basics
Given: public class Marklist { int num; public static void graceMarks(Marklist obj4) { obj4.num += 10; } public static void main(String[] args) { MarkList obj1 = new MarkList(); Ma...
object creationobject referencesnullpass-by-value - Question #227Working with Methods and Encapsulation
Given: class Cake { int model; String flavor; Cake() { model = 0; flavor = "Unknown"; } } public class Test { public static void main(String[] args) { Cake c = new Cake(); bake1(c)...
object stateconstructorsmethod callsobject references - Question #228Working with Methods and Encapsulation
Given: public class Painting { private String type; public String getType() { return type; } public void setType(String type) { this.type = type; } public static void main(String[]...
getterssettersnull valuesString - Question #229Working with Methods and Encapsulation
Given: class Base { // insert code here } public class Derived extends Base{ public static void main(String[] args) { Derived obj = new Derived(); obj.setNum(3); System.out.println...
encapsulationaccess modifiersinheritancegetters - Question #230Handling Exceptions
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...
arraysArrayIndexOutOfBoundsExceptiontry-catchfor loop - Question #231Working with Selected Classes from the Java API
Given: public class Equal { public static void main(String[] args) { String str1 = "Java"; String[] str2 = {"J","a","v","a"}; String str3 = ""; for (String str : str2) { str3 = str...
String comparisonequals()== operatorString concatenation - Question #232Creating and Using Arrays
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...
arraysarray assignmentfor-each loop - Question #233Using Loop Constructs
Given: public class TestLoop1 { public static void main(String[] args) { int a = 0, z=10; while (a < z) { a++; --z; } System.out.print(a + " : " + z); } } What is the result?
while loopincrement operatordecrement operatorloop tracing - Question #234Using Loop Constructs
Given: public class MyClass { public static void main(String[] args) { while (int ii = 0; ii < 2) { ii++; System.out.println("ii = " + ii); } } } What is the result?
while loop syntaxvariable scopecompilation errors - Question #235Working with Selected Classes from the Java API
Given: public class String1 { public static void main(String[] args) { String s = "123"; if (s.length() >2) s.concat("456"); for(int x = 0; x <3; x++) s += "x"; System.out.println(...
String immutabilityString concatenationconcat()for loop - Question #236Using Operators and Decision Constructs
Given the code fragment: float x = 22.00f % 3.00f; int y = 22 % 3; System.out.print(x + ", "+ y); What is the result?
modulo operatorfloatintarithmetic operators - Question #238Handling Exceptions
Given: class MarksOutOfBoundsException extends IndexOutOfBoundsException { } public class GradingProcess { void verify(int marks) throws IndexOutOfBoundsException { if (marks > 100...
custom exceptionsexception hierarchytry-catchcommand-line argumentsInteger.parseInt() - Question #239Working with Selected Classes from the Java API
Given the code fragment: StringBuilder sb = new StringBuilder ( ) ; Sb.append ("world"); Which code fragment prints Hello World?
StringBuilderinsert()append() - Question #240Working with Methods and Encapsulation
Given: package p1; public interface DoInterface { void method1(int n1); // line n1 } package p3; import p1.DoInterface; public class DoClass implements DoInterface { public DoClass...
interfacesaccess modifierspackagemethod overriding - Question #241Creating and Using Arrays
Given the fragment: String[][] arra = new String[3][]; arra[0] = new String[]{"rose", "lily"}; arra[1] = new String[]{"apple", "berry","cherry","grapes"}; arra[0] = new String[]{"b...
2D arraysarray declarationragged arrays - Question #242Creating and Using Arrays
Given the code fragment: public class Test { static String[][] arr =new String[3][]; private static void doPrint() { //insert code here } public static void main(String[] args) { S...
2D arraysnested loopsarray indexing - Question #243Working with Java Data Types
Given: public class FieldInit { char c; boolean b; float f; void printAll() { System.out.println("c = " + c); System.out.println("c = " + b); System.out.println("c = " + f); } publ...
default valuesprimitive data typesinstance variablesmember initialization - Question #244Creating and Using Arrays
Given the code fragment: String[] cartoons = {"tom","jerry","micky","tom"}; int counter =0; if ("tom".equals(cartoons[0])) { counter++; } else if ("tom".equals(cartoons[1])) { coun...
arraysstring comparisonconditional statementsarray indexing - Question #245Using Operators and Decision Constructs
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"...
switch statementcontrol flowtype compatibilitybreak statement - Question #246Creating and Using Arrays
Given: public class Test { public static void main(String[] args) { try { String[] arr =new String[4]; arr[1] = "Unix"; arr[2] = "Linux"; arr[3] = "Solarios"; for (String var : arr...
arraysdefault valuesenhanced for loopexception handling - Question #247Using Operators and Decision Constructs
Given the code fragment int var1 = -5; int var2 = var1--; int var3 = 0; if (var2 < 0) { var3 = var2++; } else { var3 = --var2; } System.out.println(var3); What is the result?
operatorsincrement/decrementconditional statementsside effects - Question #248Working with Selected Classes from the Java API
Given the code fragment: List colors = new ArrayList(); colors.add("green"); colors.add("red"); colors.add("blue"); colors.add("yellow"); colors.remove(2); colors.add(3,"cyan"); Sy...
ArrayListcollectionslist operationsindex-based operations - Question #249Using Operators and Decision Constructs
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?
operatorsoperator precedencearithmetic operationsinteger division - Question #250Working with Inheritance
Given: class Sports { int num_players; String name, ground_condition; Sports(int np, String sname, String sground){ num_players = np; name = sname; ground_condition = sground; } }...
inheritanceconstructorssuper keywordconstructor chaining - Question #251Java Basics
Given: public class X { static int i; int j; public static void main(String[] args) { X x1 = new X(); X x2 = new X(); x1.i = 3; x1.j = 4; x2.i = 5; x2.j = 6; System.out.println( x1...
static membersinstance membersvariablesobject state - Question #253Working with Methods and Encapsulation
Given the code fragment? public class Test { public static void main(String[] args) { Test t = new Test(); int[] arr = new int[10]; arr = t.subArray(arr,0,2); } // insert code here...
method signaturereturn typesparametersarrays - Question #254Working with Methods and Encapsulation
Given: public class TestField { int x; int y; public void doStuff(int x, int y) { this.x = x; y =this.y; } public void display() { System.out.print(x + " " + y + " : "); } public s...
this keywordinstance variablesmethod parametersobject state - Question #255Working with Java Data Types
Given: package p1; public class Test { static double dvalue; static Test ref; public static void main(String[] args) { System.out.println(ref); System.out.println(dvalue); } } What...
default valuesstatic membersreference typesprimitive data types