1Z0-803 Exam Questions
266 real 1Z0-803 exam questions with expert-verified answers and explanations. Page 1 of 6.
- Question #1Handling Exceptions
Given: Which two actions, used independently, will permit this class to compile?
checked exceptionsexception handlingmethod signaturesthrows keyword - Question #2Using Operators and Decision Constructs
Given: What is the result?
switch statementcontrol flowstring in switch - Question #3Working with Java Data Types
Given: Which statement, when inserted into line "// TODO code application logic here ", is valid change?
type compatibilityobject assignmentpolymorphismcasting - Question #4Using Operators and Decision Constructs
Given the code fragment: System.out.println("Result: " + 2 + 3 + 5); System.out.println("Result: " + 2 + 3 * 5); What is the result?
string concatenationoperator precedencearithmetic operators - Question #5Java Basics
Which code fragment is illegal?
java syntaxcompilation errorslegal code constructs - Question #6Working with Selected Classes from the Java API
Given: What is the result?
string methodsstring indexingStringIndexOutOfBoundsExceptionruntime exceptions - Question #7Using Operators and Decision Constructs
Given the code fragment: int a = 0; a++; System.out.println(a++); System.out.println(a); What is the result?
increment operatorpost-incrementoperator evaluation - Question #8Working with Methods and Encapsulation
Given a java source file: What changes will make this code compile?
access modifiersmethod declarationconstructor declarationencapsulation - Question #9Working with Selected Classes from the Java API
Given: What is the result?
string comparisonequals methodequality operatorstring pool - Question #10Java Basics
Given: What three modifications, made independently, made to class greet, enable the code to compile and run?
packagesimport statementsobject instantiationfully qualified names - Question #11Using Operators and Decision Constructs
Given: Which three lines will compile and output "right on!"?
conditional statementsboolean logicoperatorscontrol flow - Question #12Working with Selected Classes from the Java API
Given the code fragment: String h1 = "Bob"; String h2 = new String ("Bob"); What is the best way to test that the values of h1 and h2 are the same?
string comparisonequals methodequality operator - Question #13Creating and Using Arrays
Which two are valid declarations of a two-dimensional array?
array declarationmultidimensional arraysarray syntax - Question #14Using Loop Constructs
Given: Which two are possible outputs?
control flowconditional logicloop executionprogram output - Question #15Using Operators and Decision Constructs
Given the code fragment: System.out.println ("Result:" +3+5); System.out.println ("result:" + (3+5)); What is the result?
string concatenationoperator precedencearithmetic operators - Question #16Handling Exceptions
A method doSomething () that has no exception handling code is modified to trail a method that throws a checked exception. Which two modifications, made independently, will allow t...
checked exceptionsexception handlingthrows keywordtry-catch block - Question #17Java Basics
Which two may precede the word "class" in a class declaration?
class modifiersaccess modifiersstatic keyword - Question #18Using Loop Constructs
Given the code fragment: What is the result?
loop constructsconditional statementsprogram tracing - Question #19Using Operators and Decision Constructs
Given: What code should be inserted?
code completionconditional logicloop control - Question #20Handling Exceptions
Which three are bad practices?
exception handling best practicesruntime exceptionschecked exceptionsError class - Question #21Working with Java Data Types
Given: Which two declarations will compile?
variable declarationprimitive typessyntax - Question #22Java Basics
Given: class X {} class Y {Y () {}} class Z {z(int i ) {} } Which class has a default constructor?
constructorsdefault constructorclass definition - Question #23Using Loop Constructs
Given the code fragment: What values of x, y, z will produce the following result? 1 2 3 4 1 2 3 4 1 2 3 4 ------ 1 2 3 4 ------
nested loopsloop controloutput prediction - Question #24Working with Selected Classes from the Java API
Which statement initializes a stringBuilder to a capacity of 128?
StringBuilderconstructorscapacityJava API - Question #25Using Operators and Decision Constructs
Given: What is the result?
operatorsexpression evaluationtype conversion - Question #26Working with Methods and Encapsulation
A method is declared to take three arguments. A program calls this method and passes only two arguments. What is the result?
method invocationmethod signaturecompilation errorarguments - Question #27Using Operators and Decision Constructs
Given the fragment: What is the result?
operatorsexpression evaluationcontrol flow - Question #28Using Operators and Decision Constructs
Given the following code fragment: What is the result if the integer value is 33?
conditional statementsif-elseswitchoutput prediction - Question #29Handling Exceptions
Which three are advantages of the Java exception mechanism?
exception handlingprogram structurecustom exceptions - Question #30Using Loop Constructs
Given the code fragment: Boolean b1 = true; Boolean b2 = false; int 1 = 0; while (foo) {} Which one is valid as a replacement for foo?
while loopboolean expressionsoperators - Question #31Working with Inheritance
Given: What should statement1, statement2, and statement3, be respectively, in order to produce the result? Shape: constructor Square: foo Shape: foo
inheritanceconstructorsmethod overridingpolymorphism - Question #32Java Basics
Give: Public Class Test { } Which two packages are automatically imported into the java source file by the java compiler?
package importjava.langdefault packagecompilation - Question #33Working with Inheritance
Given: What is the reference type of myZ and what is the type of the object it references?
polymorphismreference typesobject typesinheritance - Question #34Working with Inheritance
Given: What is the result?
runtime typeobject typepolymorphismgetClass() - Question #35Using Loop Constructs
Given the code fragment: How many times is 2 printed?
loopsconditional statementsoutput predictioniteration count - Question #36Java Basics
Given: What is the result?
compilation errorobject methodshashCodesyntax - Question #37Working with Inheritance
Given: What is true about the class Wow?
abstract classesabstract methodsinheritance rules - Question #38Creating and Using Arrays
Which two will compile, and can be run successfully using the command: Java fred1 hello walls
main methodcommand-line argumentsarraysString[] args - Question #39Using Operators and Decision Constructs
Given: What is the result?
operatorstype conversionexpression evaluation - Question #40Using Operators and Decision Constructs
Given: What is the result?
compilation errorswitch statementcontrol flowsyntax - Question #41Working with Inheritance
Which two statements are true?
abstract classesinterfacesinheritancepolymorphism - Question #42Handling Exceptions
The catch clause argument is always of type___________.
catch clauseexception handlingThrowable - Question #43Working with Selected Classes from the Java API
Given: public class x{ public static void main (string [] args){ String theString = "Hello World"; System.out.println(theString.charAt(11)); } } What is the result?
String methodscharAt()StringIndexOutOfBoundsException - Question #44Using Operators and Decision Constructs
Given the code fragment: What is the result?
operatorsconditional statementsmethod callscontrol flow - Question #45Working with Methods and Encapsulation
View the exhibit: What is the result when this program is executed?
object creationconstructorsinstance variablesmethod invocation - Question #46Java Basics
Given the code fragment: What is the result?
compilation errorssyntax rulestype compatibility - Question #47Using Operators and Decision Constructs
Given: What is the result?
operatorsarithmetic operationsoperator precedence - Question #48Creating and Using Arrays
Which two are valid instantiations and initializations of a multi dimensional array?
multi-dimensional arraysarray initializationarray declaration - Question #49Handling Exceptions
An unchecked exception occurs in a method dosomething() Should other code be added in the dosomething() method for it to compile and execute?
unchecked exceptionsexception handlingthrows clause - Question #50Working with Inheritance
Given the code fragment: interface SampleClosable { public void close () throws java.io.IOException; } Which three implementations are valid?
interfacesmethod overridingexception handlingIOException