Question 161 · 200 in bank
What is the name of the Java concept that uses access modifiers to protect variables and hide them within a class?
Show answer
Answer: A
Java SE 8 Programmer I200 questions across 20 pages are complete and free, with no account or card.
200 questions in this bank
Free access · progress saved on this device
What is the name of the Java concept that uses access modifiers to protect variables and hide them within a class?
Answer: A
Given the code fragment:
Which code fragment, when inserted at line n1, enables the App class to print Equal?
Answer: B
B is the correct option because == operator checks the same address and as str1 and str2 have different addresses but same content.
Source: Adapted from community discussion — kkaayyyy
Given the code fragment:
What is the result?
Answer: A
The correct answer is A because when i = 4, arr[4] does not exist, causes the ArrayIndexOutOfBoundsException. I tested on eclipse and return this answer.
Source: Adapted from community discussion — iSnover
Given the code fragment:
What is the result?
Answer: D
To add to the explanation: The JVM throws a null pointer exception because a method (concat()) is called on an object containing null. Note that the print() method does not cause JVM to throw an exception and prints null.
Source: Adapted from community discussion — Saftschnitzel
Given:
What is the result?
Answer: D
this() and super() cannot both be used in the same constructor call: In a single constructor, you can either call another constructor in the same class using this() or call a constructor in the superclass using super(). You cannot use both of them in a single constructor call.
Source: Adapted from community discussion — SoNofPATEL
Given the code fragment:
Which three lines fail to compile? (Choose three.)
Answer: BCE
We can't convert larger data type into smaller data type without using explicit type casting. Eg: float f=100.1f; int i=f; //we can't do this int x=(int) f; //explicit type casting we can do this
Source: Adapted from community discussion — Joker74
Given:
What is the result?
Answer: C
correct. You can overload the main() method, but only public static void main(String[] args) will be used when your class is launched by the JVM.
Source: Adapted from community discussion — letmein2
Given the code fragment:
Which two modifications, made independently, enable the code to compile? (Choose two.)
Answer: CD
C, D Cannot reduce the visibility of the inherited method from an abstract class. In this case, can't change resolve from protected > default But you can change it to protected > protected protected > public
Source: Adapted from community discussion — Ancient1
Given the following code:
What are the values of each element in intArr after this code has executed?
Answer: C
package p1; public class Test { public static void main(String[] args) { int[] intArr = {15,30,45,60,75}; intArr[2] = intArr[4]; intArr[4] = 90; /* this is for testing code * for (int i = 0; i < intArr.length; i++) { System.out.printf("\n intArr[%d]=" * + intArr[i], i); } */ } }
Source: Adapted from community discussion — GauriKatara
Given the content of three files:
Which statement is true?
Answer: A
Correct answer is A. class B won't compile as we can't have private or protected variables in a block. class C won't compile as package declaration should be first statement followed by import statement (s).
Source: Adapted from community discussion — ashwinbalu
Keyboard:J Kmove between questionsA–Dselect an answerRshow or hide the answer← →change page
1Z0-808 practice, question 161. 200 questions available.
Version 1.0.0. How we source questions