ocpjp Questions

8

Solved

One of the correct answers from OCP Java SE 6 Programmer Practice Exams is: You can programmatically test wheather assertions have been enabled without throwing an AssertionError. How can I ...
Dripping asked 23/10, 2012 at 11:57

5

Is anybody aware of any real life use of the class AtomicLongFieldUpdate? I have read the description but I have not quite grasped the meaning of it. Why do I want to know that? Curiosity and for ...
Forgave asked 21/6, 2013 at 16:0

10

Solved

I was just studying OCPJP questions and I found this strange code: public static void main(String a[]) { System.out.println(Double.NaN==Double.NaN); System.out.println(Double.NaN!=Double.NaN); }...
Jonas asked 11/1, 2012 at 13:2

3

Solved

public class Java{ public static void main(String[] args){ final byte x = 1; final byte y = 2; byte z = x + y;//ok System.out.println(z); byte a = 1; byte b = 2; byte c = a + b; //Compiler...
Majewski asked 27/10, 2012 at 12:3

4

Solved

Can someone explain this code? public class SneakyThrow { public static void sneakyThrow(Throwable ex) { SneakyThrow.<RuntimeException>sneakyThrowInner(ex); } private static <T ext...
Bullwhip asked 26/12, 2012 at 9:40

2

Solved

I'm prepping up for the Java 8 certificate and the following has me puzzled a littlebit, maybe someone can help me with this? In the example, a Squirrel class is modelled. It has a name and a...
Dapple asked 24/3, 2018 at 20:36

6

I'm preparing for the SCJP (recently rebranded as OCPJP by Oracle) and one particular question that I got wrong on a mock exam has confused me, the answer description doesn't explain things clear e...
Bedstead asked 25/9, 2012 at 18:50

2

I am reading the book of OCA & OCP for java 7 certification and I am trying the exercises of the book with java 8 and I noticed something wired. I have Class1 class as follows: package cert;...
Reverse asked 11/4, 2017 at 13:3

1

Solved

I am preparing for an OCPJP 8 exam for the next 2 months and currently I this one got my attention as I dont understand why public class BiPredicateTest { public static void main(String[] args) { ...
Eth asked 25/3, 2017 at 18:10

3

Solved

Code: public class Foo { static void test(String s){ System.out.println("String called"); } static void test(int s){ System.out.println("int called"); } public static void main(String[] ...
Contribution asked 10/11, 2016 at 6:21

1

Solved

During my studies to the OCPJP8 I've encountered one question which doesn't have very clear answer to me. Consider following code: public class Animals { class Lamb implements Closeable { public ...
Passageway asked 27/10, 2015 at 19:24

1

Solved

I am studying for the Java OCP certificate. I am taking mock exams to prepare. Example program: public class Quetico { public static void main(String[] args) { Pattern p = Pattern.compile(args[...
Komsomolsk asked 25/7, 2015 at 18:28

3

Solved

I was doing a question out of the book oracle_certified_professional_java_se_7_programmer_exams_1z0-804_and_1z0-805 by Ganesh and Sharma. One question is: Consider the following program...
Naturalize asked 9/10, 2014 at 14:21

4

Solved

Why is the output in this example 1? public static void main(String[] args){ int[] a = { 1, 2, 3, 4 }; int[] b = { 2, 3, 1, 0 }; System.out.println( a [ (a = b)[3] ] ); } I thought it wou...
Samellasameness asked 4/12, 2011 at 11:25

1

Solved

I'm preparing for OCPJP exam and I ran into the following example: class Test { public static void main(String args[]) { String test = "I am preparing for OCPJP"; String[] tokens = test.split("...
Alethaalethea asked 7/3, 2014 at 20:8

2

Solved

I am trying to execute simple query using below DbQuery.java class which uses DbConnector to get a Connection from DriverManager. note: I have already included "mysql-connector-java-5.1.25-bin...
Oder asked 6/7, 2013 at 21:47

3

Solved

I am preparing for OCPJP, and I got stuck at the following mock exam question: Given: 3. interface Animal { void makeNoise(); } 4. class Horse implements Animal { 5. Long weight = 1200L; 6. publ...
Joejoeann asked 29/11, 2012 at 21:8

3

Solved

If enum implements Comparable so why can't compare with < or >? public class Dream { public static void main(String... args) { System.out.println(PinSize.BIG == PinSize.BIGGER); //false Sy...
Downstream asked 25/10, 2012 at 13:56

4

Solved

After reading some of the SCJP certification last night, I got thinking about switch statements and how the expressions are evaluated, and I'm a little puzzled by something. Java won't let you swi...
Gearhart asked 8/8, 2012 at 10:30

2

Solved

Possible Duplicate: Inconsistent behavior on java's == Integer wrapper objects share the same instances only within the value 127? I have found the following == behaviour for Int...
Glade asked 17/2, 2012 at 11:13

3

Solved

In the following program class ZiggyTest2 { public static void main(String[] args){ double x = 123.456; char c = 65; int i = 65; System.out.printf("%s",x); System.out.printf("%b",x); Sy...
Pimple asked 25/12, 2011 at 14:20

7

Solved

When i run the following example i get the output 0,2,1 class ZiggyTest2{ static int f1(int i) { System.out.print(i + ","); return 0; } public static void main(String[] args) { int i ...
Posology asked 23/12, 2011 at 11:53

2

Solved

In preparation for the SCJP (or OCPJP as it's now known) exam, I'm being caught out by some mock questions regarding pass-by-(reference)value and immutability. My understanding, is that when you p...
Niedersachsen asked 2/12, 2011 at 13:8

2

Solved

I'm studying up for the SCJP exam, upon doing some mock tests I came across this one : It asks what is the output of the following : class TestClass { int i = getInt(); int k = 20; public int ...
Duckling asked 21/11, 2011 at 20:26

15

Solved

I'm studying for the OCPJP exam, and so I have to understand every little strange detail of Java. This includes the order in which the pre- and post-increment operators apply to variables. Th...
Echinoderm asked 7/11, 2011 at 16:0

© 2022 - 2024 — McMap. All rights reserved.