1Z0-803 Exam Questions
266 real 1Z0-803 exam questions with expert-verified answers and explanations. Page 3 of 6.
- Question #101Working with Java Data Types
Which code fragment cause a compilation error?
primitive typesfloatdoubleliterals - Question #102Working with Methods and Encapsulation
Given: class X { static void m (int[] i) { i[0] += 7; } public static void main (String[] args) { int[] j = new int[1]; j[0] = 12; m(j); System.out.println(j[0]); } } What is the r...
arraysmethod parameterspass by valuereference types - Question #103Working with Inheritance
Given: 1. public class SampleClass { 2. public static void main (String[] args) { 3. AnotherSampleClass asc = new AnotherSampleClass(); 4. SampleClass sc = new SampleClass(); 5. //...
inheritancepolymorphismtype castingobject assignment - Question #104Working with Selected Classes from the Java API
Which statement will empty the contents of a StringBuilder variable named sb?
StringBuilderString manipulationAPI methods - Question #105Handling Exceptions
Given: class MarksOutOfBoundsException extends IndexOutOfBoundsException { } public class GradingProcess { void verify(int marks) throws IndexOutOfBoundsException { if (marks > 100...
exception handlinginheritanceruntime exceptionscommand line arguments - Question #106Working with Inheritance
Given: 1. interface Pet { } 2. class Dog implements Pet { } 3. class Beagle extends Dog { } Which three are valid?
interfacesinheritancepolymorphismtype compatibility - Question #107Working with Selected Classes from the Java API
Given the code fragment: StringBuilder sb = new StringBuilder(); sb.append("World"); Which fragment prints Hello World?
StringBuilderString manipulationAPI methods - Question #108Working with Inheritance
Given: package pkg1; class Bb { } public class Ee { private Ee() { } } package pkg2; final class Ww; package pkg3; public abstract class Dd { void m() { } } And, 1. package pkg4; 2...
inheritanceaccess modifierspackagesconstructors - Question #109Working with Java Data Types
Given: 1. public class Simple { 2. public float price; 3. public static void main (String [] args) { 4. Simple price = new Simple(); 5. price = 4; 6. } 7. } Which will make this co...
variable scopeshadowingprimitive assignmentobject fields - Question #110Java Basics
Given the code fragment: Which statement is true?
garbage collectionobject lifecyclereferences - Question #111Creating and Using Arrays
Given: public class Test { public static void main (String[] args) { char[] arr = {97, '\t', 'e', '\n', 'i', '\t', 'o'}; for (char var: arr) { System.out.print(var); } System.out.p...
arraysenhanced for loopcharacter literalsoutput - Question #112Working with Inheritance
Given the class definitrions: class Shape { } class Square extends Shape { } Given the variable declarations: Shape shape1 = null; Square square1 = null; Which four compile?
inheritancepolymorphismtype castingupcastingdowncasting - Question #113Working with Methods and Encapsulation
Given the code fragments: 9. class Student { 10. int rollnumber; 11. String name; 12. List courses = new ArrayList(); 13. // insert code fragment here 14. public String toString()...
constructorsaccess modifiersmethod signaturesdata types - Question #114Using Loop Constructs
Given: What is the result?
for looploop iterationconditional logicoutput - Question #115Using Operators and Decision Constructs
Given: What is the result?
operatorsvariable manipulationoutput - Question #116Creating and Using Arrays
Which two are valid declarations of a two-dimensional array?
arraysmulti-dimensional arraysarray declaration syntax - Question #117Using 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 a...
nested loopsvariable shadowingloop constructsinstance variables - Question #118Using Operators and Decision Constructs
Given: public class CheckIt { public static void main (String[] args) { if (doCheck()) { System.out.print("square "); } System.out.print("..."); } public static int doCheck() { ret...
conditional statementsboolean expressionstype compatibilitycompilation errors - Question #119Working with Inheritance
Given: public class Test { } From which class does the Java compiler implicitly derive Test?
inheritanceObject classclass hierarchy - Question #120Using Operators and Decision Constructs
Given: 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": Syst...
switch statementcontrol flowtype compatibilityliterals - Question #121Using Operators and Decision Constructs
Given: class App { private boolean flag; public void displayResult() { int result = flag ? 5 : 10; System.out.print("Result = " + result++); } public static void main (String[] arg...
default valuesternary operatorpost-increment operatorprimitive data types - Question #122Working 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()...
inheritanceabstract classesmethod overridingpolymorphism - Question #123Java Basics
Given: What is the result?
string manipulationmethod callsprogram output - Question #124Working with Inheritance
Given: public abstract class Wow { private int wow; public Wow (int wow) { this.wow = wow; } public void wow() { } private void wowza() { } } Which is true about the class Wow?
abstract classesaccess modifiersconstructorsinstance variables - Question #125Working with Java Data Types
Given: class Prime { int num; Prime(int num) { this.num = num; } } public class Test { public static void main (String[] args) { Prime obj1 = new Prime(13); Prime obj2 = new Prime(...
object equalityreference comparisonequals methodconstructors - Question #126Using Operators and Decision Constructs
Given the code fragment: String[] cartoons = {"tom", "jerry", "micky", "tom"}; int counter = 0; And, if ("tom".equals(cartoons[0])) { counter++; } else if ("tom".equals(cartoons[1]...
string arraysif-else ifstring equals methodconditional logic - Question #127Working with Selected Classes from the Java API
Given: class X { static void m(StringBuilder sb1) { sb1.append("er"); } public static void main (String[] args) { StringBuilder sb2 = new StringBuilder("moth"); m(sb2); System.out....
StringBuildermethod parameterspass by value (reference)mutability - Question #129Using Loop Constructs
Given: public class DoWhile1 { public static void main (String[] args) { int i = 2; do { System.out.println(i); } while (--i); } } What is the result?
do-while loopimplicit type conversionboolean expressionscompilation errors - Question #130Java Basics
Given the code fragment: Which two code fragments, inserted independently, enable the code to compile?
instance variablesobject referencefield accesscompilation errors - Question #131Working with Inheritance
Given: class X { private X() { } void one() { } } public class Y extends X { private Y() { } public static void main (String[] args) { new Y().one(); } } Which change will make thi...
constructorsaccess modifiersinheritancesubclassing - Question #132Using Loop Constructs
Given: public class App { public static void main(String[] args) { char[] arr = {'A', 'e', 'I', 'O', 'u'}; int count = 0; for (int i = 0; i < arr.length; i++) { switch (arr[i]) { c...
for loopswitch statementcontinue keywordbreak keywordchar data type - Question #133Java 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(); M...
object creationreference variablespass by referencememory management - Question #134Using Loop Constructs
Given: What is the result?
loop constructsprogram flowoutput behaviorconditional logic - Question #135Working with Methods and Encapsulation
Given: class X { String str = "default"; int ivalue = 17; X(String s) { str = s; } X(int i) { ivalue = i; } void print() { System.out.println(str + " " + ivalue); } public static v...
constructorsoverloadinginstance variablesobject state - Question #136Handling Exceptions
Which four statements are true regarding exception handling in Java?
exception handlingtry-catch-finallychecked exceptionsmulti-catchexception hierarchy - Question #137Java Basics
Given: Which two code fragments are valid?
java syntaxcode validitycompilation - Question #138Working with Selected Classes from the Java API
Given the code fragment: class MySearch { public static void main(String[] args) { if (XXXX) { System.out.println("Found"); } } } Which code fragment, replace with XXXX, enables th...
String methodsindexOfconditional statementsboolean expressions - Question #139Java Basics
Which three statements are true about the structure of a Java class?
class structureconstructorsmethod overloadingfield initializationdefault values - Question #140Working with Selected Classes from the Java API
Given: class Lang { private String category = "procedura1"; public static void main (String[] args) { Lang obj1 = new Lang(); Lang obj2 = new Lang(); if (obj1.category == obj2.cate...
string literalsstring poolobject equalityequals methodreference comparison - Question #141Using Operators and Decision Constructs
Given the code fragment: public static void main(Stirng[] args) { int x = 353; int j = x++; switch (j) { case 317: case 353: case 367: System.out.println("Is a prime number."); cas...
switch statementduplicate case labelcompilation error - Question #142Using Operators and Decision Constructs
Given the code fragment: boolean log1 = (1 < 9) && (1 > 5); boolean log2 = (3 == 4) || (3 == 3); System.out.println("log1:" + log1 + "\nlog2:" + log2); What is the result?
boolean operatorslogical ANDlogical OR - Question #143Working with Selected Classes from the Java API
Given: public class Case { public static void main(String[] args) { String product = "Pen"; product.toLowerCase(); product.concat(" BOX".toLowerCase()); System.out.print(product.su...
String immutabilityString methodsStringIndexOutOfBoundsException - Question #144Java Basics
Given: public class Test { } Which two packages are automatically imported into the Java source file by the Java compiler?
package importjava.langdefault package - Question #145Working 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)...
pass by valueobject referencesmethod parameters - Question #146Working with Selected Classes from the Java API
Given: class X { static void m(String s1) { s1 = "acting"; } public static void main(String[] args) { String s2 = "action"; m(s2); System.out.println(s2); } } What is the result?
String immutabilitypass by valuemethod parameters - Question #147Working 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[...
null referenceString concatenationgetter/setter methods - Question #148Handling Exceptions
Which two statement correctly describe checked exception?
checked exceptionsException hierarchyexception types - Question #149Using Operators and Decision Constructs
Given the code fragment: What is the result?
boolean expressionscomparison operators - Question #150Working with Methods and Encapsulation
You are writing a method that is declared not to return a value. Which two are permitted in the method body?
void methodsreturn statementmethod signature - Question #151Working with Methods and Encapsulation
Given: public class Access { private int x = 0; private int y = 0; public static void main(String[] args) { Access accApp = new Access(); accApp.printThis(1, 2); accApp.printThat(3...
this keywordinstance variablesmethod parameters