1Z0-803 Practice Questions
269 real 1Z0-803 exam questions with expert-verified answers and explanations. Page 3 of 6.
- Question #101
Which code fragment cause a compilation error?
- Question #102
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...
- Question #103
Given: 1. public class SampleClass { 2. public static void main (String[] args) { 3. AnotherSampleClass asc = new AnotherSampleClass(); 4. SampleClass sc = new SampleClass(); 5. //...
- Question #104
Which statement will empty the contents of a StringBuilder variable named sb?
- Question #105
Given: class MarksOutOfBoundsException extends IndexOutOfBoundsException { } public class GradingProcess { void verify(int marks) throws IndexOutOfBoundsException { if (marks > 100...
- Question #106
Given: 1. interface Pet { } 2. class Dog implements Pet { } 3. class Beagle extends Dog { } Which three are valid?
- Question #107
Given the code fragment: StringBuilder sb = new StringBuilder(); sb.append("World"); Which fragment prints Hello World?
- Question #108
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...
- Question #109
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...
- Question #110
Given the code fragment: Which statement is true?
- Question #111
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...
- Question #112
Given the class definitrions: class Shape { } class Square extends Shape { } Given the variable declarations: Shape shape1 = null; Square square1 = null; Which four compile?
- Question #113
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()...
- Question #114
Given: What is the result?
- Question #115
Given: What is the result?
- Question #116
Which two are valid declarations of a two-dimensional array?
- Question #117
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...
- Question #118
Given: public class CheckIt { public static void main (String[] args) { if (doCheck()) { System.out.print("square "); } System.out.print("..."); } public static int doCheck() { ret...
- Question #119
Given: public class Test { } From which class does the Java compiler implicitly derive Test?
- Question #120
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...
- Question #121
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...
- Question #122
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()...
- Question #123
Given: What is the result?
- Question #124
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?
- Question #125
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(...
- Question #126
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]...
- Question #127
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....
- Question #128
Which is a valid abstract class?
- Question #129
Given: public class DoWhile1 { public static void main (String[] args) { int i = 2; do { System.out.println(i); } while (--i); } } What is the result?
- Question #130
Given the code fragment: Which two code fragments, inserted independently, enable the code to compile?
- Question #131
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...
- Question #132
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...
- Question #133
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...
- Question #134
Given: What is the result?
- Question #135
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...
- Question #136
Which four statements are true regarding exception handling in Java?
- Question #137
Given: Which two code fragments are valid?
- Question #138
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...
- Question #139
Which three statements are true about the structure of a Java class?
- Question #140
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...
- Question #141
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...
- Question #142
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?
- Question #143
Given: public class Case { public static void main(String[] args) { String product = "Pen"; product.toLowerCase(); product.concat(" BOX".toLowerCase()); System.out.print(product.su...
- Question #144
Given: public class Test { } Which two packages are automatically imported into the Java source file by the Java compiler?
- Question #145
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)...
- Question #146
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?
- Question #147
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[...
- Question #148
Which two statement correctly describe checked exception?
- Question #149
Given the code fragment: What is the result?
- Question #150
You are writing a method that is declared not to return a value. Which two are permitted in the method body?