1Z0-803 Practice Questions
269 real 1Z0-803 exam questions with expert-verified answers and explanations. Page 2 of 6.
- Question #51
Given the code fragment: What is the result?
- Question #52
Given the following code: What will make this code compile and run?
- Question #53
Given: What is the result?
- Question #54
You are writing a method that is declared not to return a value. Which two are permitted in the method body?
- Question #55
Identify two benefits of using ArrayList over array in software development.
- Question #56
Which three are valid types for switch?
- Question #57
Give: What value should replace KK in line x to cause jj = 5 to be output?
- Question #58
Given the following code fragment: What is the result if the integer value is 33?
- Question #59
Given the code fragment: Int [] [] array = {{0}, {0, 1}, {0, 2, 4}, {0, 3, 6, 9}, {0, 4, 8, 12, 16}}; Systemout.printIn(array [4] [1]); System.out.printIn (array) [1][4]); int [] [...
- Question #60
Given: How many times is 2 printed as a part of the output?
- Question #61
Given: Which line causes a compilation error?
- Question #62
Given: What is the result?
- Question #63
Given: Which approach ensures that the class can be compiled and run?
- Question #64
Given: What is the result?
- Question #65
Which declaration initializes a boolean variable?
- Question #66
Given: Why will the code not compile?
- Question #67
Given: This class is poorly encapsulated. You need to change the circle class to compute and return the area instead. What three modifications are necessary to ensure that the clas...
- Question #68
Given a code fragment: What is the result?
- Question #69
Which two are possible outputs? public class Two { public static void main(String[] args) { try { doStuff(); system.out.println("1"); } catch { system.out.println("2"); }} public s...
- Question #70
Given: public class MyFor { public static void main(String[] args) { for (int ii = 0; ii < 4; ii++) { System.out.println("ii = "+ ii); ii = ii +1; } } } What is the result?
- Question #71
Given the code fragment: int [][] array2d = new int[2][3]; System.out.println("Loading the data."); for ( int x = 0; x < array2d.length; x++) { for ( int y = 0; y < array2d[0].leng...
- Question #72
Given: public class DoBreak1 { public static void main(String[] args) { String[] table = {"aa", "bb", "cc", "dd"}; for (String ss: table) { if ( "bb".equals(ss)) { continue; } Syst...
- Question #73
Which three lines are illegal? 1. class StaticMethods { 2. static void one() { 3. two(); 4. StaticMethods.two(); 5. three(); 6. StaticMethods.four(); 7. } 8. static void two() { }...
- Question #74
Which is a valid abstract class?
- Question #75
View the exhibit: public class Student { public String name = ""; public int age = 0; public String major = "Undeclared"; public boolean fulltime = true; public void display() { Sy...
- Question #76
Given the code fragment: String name = "Spot"; int age = 4; String str ="My dog " + name + " is " + age; System.out.println(str); And StringBuilder sb = new StringBuilder(); Using...
- Question #77
Given: public class Main { public static void main(String[] args) { try { doSomething(); } catch (SpecialException e) { System.out.println(e); }} static void doSomething() { int []...
- Question #78
View the exhibit: public class Student { public String name = ""; public int age = 0; public String major = "Undeclared"; public boolean fulltime = true; public void display() { Sy...
- Question #79
What should keyword1 and keyword2 be respectively, in oreder to produce output 2345? int [] array = {1,2,3,4,5}; for (int i: array) { if ( i < 2) { keyword1 ; } System.out.println(...
- Question #80
What is the result? int i, j=0; i = (3* 2 +4 +5 ) ; j = (3 * ((2+4) + 5)); System.out.println("i:"+ i + "\nj":+j);
- Question #81
What is the result? boolean log3 = ( 5.0 != 6.0) && ( 4 != 5); boolean log4 = (4 != 4) || (4 == 4); System.out.println("log3:"+ log3 + \nlog4" + log4);
- Question #82
Which statement will emoty the contents of a StringBuilder variable named sb?
- Question #83
What is the result? Class StaticField { static int i = 7; public static void main(String[] args) { StaticFied obj = new StaticField(); obj.i++; StaticField.i++; obj.i++; System.out...
- Question #84
Which two are valid array declaration?
- Question #85
Given: class Overloading { int x(double d) { System.out.println("one"); return 0; } String x(double d) { System.out.println("two"); return null; } double x(double d) { System.out.p...
- Question #86
Given: public class MainMethod { void main() { System.out.println("one"); } static void main(String args) { System.out.println("two"); } public static void main(String[] args) { Sy...
- Question #87
Given: public class ScopeTest { int j, int k; public static void main(String[] args) { ew ScopeTest().doStuff(); } void doStuff() { nt x = 5; oStuff2(); System.out.println("x"); }...
- Question #88
A method is declared to take three arguments. A program calls this method and passes only two arguments. What is the results?
- Question #89
Which three are valid replacements for foo so that the program will compiled and run? public class ForTest { public static void main(String[] args) { int[] arrar = {1,2,3}; for ( f...
- Question #90
Given: public class SampleClass { public static void main(String[] args) { AnotherSampleClass asc = new AnotherSampleClass(); SampleClass sc = new SampleClass(); sc = asc; System.o...
- Question #91
Given the code fragment: int b = 3; if ( !(b > 3)) { System.out.println("square"); }{ System.out.println("circle"); } System.out.println("..."); What is the result?
- Question #92
What is the proper way to defined a method that take two int values and returns their sum as an int value?
- Question #93
Which two are Java Exception classes?
- Question #94
Given the for loop construct: for ( expr1 ; expr2 ; expr3 ) { statement; } Which two statements are true?
- Question #95
What is the result? public class StringReplace { public static void main(String[] args) { String message = "Hi everyone!"; System.out.println("message = " + message.replace("e", "X...
- Question #96
Which two statements are true for a two-dimensional array?
- Question #97
Which three statements are benefits of encapsulation?
- Question #98
Given the code fragment: 1. ArrayList<Integer> list = new ArrayList<>(1); 2. list.add(1001); 3. list.add(1002); 4. System.out.println(list.get(list.size())); What is the result?
- Question #99
Given the code fragment: Which code fragment prints blue, cyan, ?
- Question #100
View the Exhibit. public class Hat { public int ID =0; public String name = "hat"; public String size = "One Size Fit All"; public String color=""; public String getName() { return...