반응형
자격증/OCJP_ExamC2018. 7. 26. 06:40QUESTION 48

QUESTION 48 Given that the current directory is empty, and that the user has read and write privileges to the current directory, and the following: 1. import java.io.*; 2. public class Maker { 3. public static void main(String[] args) { 4. File dir = new File("dir"); 5. File f = new File(dir, "f"); 6. } 7. } Which statement is true? A. Compilation fails. B. Nothing is added to the file system. C..

자격증/OCJP_ExamC2018. 7. 26. 06:37QUESTION 47

QUESTION 47 Given: 1. public class TestSeven extends Thread { 2. private static int x; 3. public synchronized void doThings() { 4. int current = x; 5. current++; 6. x = current; 7. } 8. public void run() { 9. doThings(); 10. } 11. } Which statement is true? A. Compilation fails. B. An exception is thrown at runtime. C. Synchronizing the run() method would make the class thread-safe. D. The data ..

자격증/OCJP_ExamC2018. 7. 26. 06:32QUESTION 46

QUESTION 46 Given class Foo { static void alpha() { /* more code here */ } void beta() { /* more code here */ } } Which two statements are true? (Choose two.) A. Foo.beta() is a valid invocation of beta(). B. Foo.alpha() is a valid invocation of alpha(). C. Method beta() can directly call method alpha(). D. Method alpha() can directly call method beta(). Solution : BC

자격증/OCJP_ExamC2018. 7. 26. 06:30QUESTION 45

QUESTION 45 Given: 1. package com.company.application; 2. 3. public class MainClass { 4. public static void main(String[] args) { 5. } 6. } And MainClass exists in the /apps/com/company/application directory. Assume the CLASSPATH environment variable is set to "." (current directory). Which two java commands entered at the command line will run MainClass? (Choose two.) A. java MainClass if run f..

자격증/OCJP_ExamC2018. 7. 26. 06:26QUESTION 44

QUESTION 44 Given: interface Fish { } class Perch implements Fish { } class Walleye extends Perch { } class Bluegill { } public class Fisherman { public static void main(String[] args) { Fish f = new Walleye(); Walleye w = new Walleye(); Bluegill b = new Bluegill(); if (f instanceof Perch) System.out.print("f-p "); if (w instanceof Fish) System.out.print("w-f "); if (b instanceof Fish) System.ou..

자격증/OCJP_ExamC2018. 7. 26. 06:20QUESTION 43

QUESTION 43 Given classes defined in two different files: 1. package packageA; 2. public class Message { 3. String getText() { 4. return "text"; 5. } 6. } And: 1. package packageB; 2. 3. public class XMLMessage extends packageA.Message { 4. String getText() { 5. return "text"; 6. } 7. 8. public static void main(String[] args) { 9. System.out.println(new XMLMessage().getText()); 10. } 11. } What ..

반응형
image