1Z0-811 Exam Questions
73 real 1Z0-811 exam questions with expert-verified answers and explanations. Page 2 of 2.
- Question #51Java Basics
Given: public class App { public static void main (String[] args) { System.out.println ("Hello Java!"); } } Which statement is true about the main method?
main methodstatic methodsmethod declarationsJVM entry point - Question #52Java Basics
Given the code fragment: public static void main (String[] args) { String name = "Rita"; int age = 14; /* line n1 */ } Which code fragment, when inserted at line n1, enables it to...
printf formattingformat specifiersSystem.out methodsString output - Question #53Java Basics
Given: public class TestFinal { final int 1 = 5; static void modify (TestFinal test) { test.1 = 99; } public static void main (String [] args) { final TestFinal tf = new TestFinal...
identifier rulesfinal keywordsyntax errorsvariable naming - Question #54Java Basics
What does import java.io* mean?
import statementspackageswildcard syntaxpackage hierarchy - Question #55Java Basics
Given: public class Test { int var1; // line n1 public static void main (String[] args) { int var2; // line n2 Test obj = new Test(); int var3 = var2 - obj.var1; System.out.println...
variable initializationinstance vs local variablesdefault valuescompilation rules - Question #56Exception Handling and Methods
Given the code fragment: int number = 1; String s = null; try { number = s.length(); number += 2; } catch (RuntimeException e) { number += 4; } System.out.println (number); What is...
NullPointerExceptionRuntimeExceptionTry-CatchException Handling - Question #57Java Basics
What is the meaning of "write once, run anywhere" in Java?
JVMPlatform IndependenceBytecodeWORA - Question #58Arrays and Logic
Given the code fragment: List<String> fls = new ArrayList<>(); fls.add("jasmine"); fls.add("rose"); fls.add("lotus"); fls.remove(2); fls.set(2, "lily"); System.out.println(fls); Wh...
ArrayListList operationsIndexingExceptions - Question #59Control Flow
Given the code fragment: int count = 0; while (count <= 10) { System.out.print (count + " "); /* line n1 */ } Which statement, when inserted at line n1, enables the code to print 0...
while loopspost-increment operatorcompound assignmentloop control - Question #60Arrays and Logic
Given the code fragment: int[] arr1 = {1, 2, 3}; int[] arr2 = new int[2]; arr2[0] = 10; System.out.print(arr1.length + " : " + arr2.length); What is the result?
array initializationarray length propertyarray syntax - Question #61Object-Oriented Programming Principles
Identify three advantages of object-oriented programming.
modularitycode reuseencapsulationOOP principles - Question #62Data Types and Operators
Given the code fragment: public static void main (String[] args) { double num = -25.67; System.out.println (Math.abs (num)); } What is the result?
Math.abs()Absolute valueMath classDouble precision - Question #63Java Basics
Identify three features of the Java programming language.
language featuresdistributedmultithreadingtype safety - Question #64Arrays and Logic
Given the code fragment: List<String> names = new ArrayList<>(); names.add("Joel"); names.add("Paul"); names.remove(0); names.remove(0); System.out.println (names.isEmpty()); names...
ArrayList operationsremove() and clear() methodscode execution tracingisEmpty() behavior - Question #65Control Flow
Given the code fragment: String[] flowers = {"lotus", "lily", "rose", "jasmine"}; for (String c : flowers) { if (c.length() < 4) { continue; } System.out.print(c + " "); if (c.leng...
break and continue statementsfor-each loopsString.length()loop execution tracing - Question #66Data Types and Operators
Given the code fragment: int a = 3; a = ++a + a++; a = --a - a--; System.out.println (a); What is the output?
Pre/Post Increment OperatorsOperator PrecedenceExpression EvaluationSide Effects - Question #67Arrays and Logic
Given the code fragment: int num[] = new int[3]; num[1] = 10; num[2] = 15; List<Integer> lst = new ArrayList<> (3); lst.add(10); lst.add(15); System.out.println (num); System.out.p...
Array toString()ArrayList toString()Object representationCollections vs Arrays - Question #68Object-Oriented Programming Principles
Given the code fragment: Random r1 = new Random(10); Random r2 = new Random(10); // line n1 if (r1.nextInt() == r2.nextInt()) { System.out.println ("Jack"); } else { System.out.pri...
Random class seedingObject instantiationnextInt() behaviorEquality comparison - Question #69Java Basics
Which package would you import to use the Random class?
package importsRandom classjava.utilStandard Library - Question #70Object-Oriented Programming Principles
Which two components can class declarations include?
class declarationsinterface implementationclass structureOOP components - Question #71Control Flow
Given: String test = "a"; for (; test.compareTo ("aaa") == 0; test = test + "a") { System.out.print (test.length () + " "); System.out.print (test); } What is the output?
String.compareTo()for loop conditionsloop executionString comparison - Question #72Java Basics
Given the code fragment: public static void main(String[] args) { int iterations = 100; while (count < iterations) { System.out.println("Iteration " + count); count++; } } What is...
variable declarationcompilation errorsvariable scopecontrol flow - Question #73Object-Oriented Programming Principles
Given the contents of the Test.java file: class MyClass { private int var1 = 100; public int var2 = 200; public void doCalc() { var1 = 100 * 2; var2 = 200 * 2; } } public class Tes...
Access ModifiersPrivate KeywordField VisibilityEncapsulation