Questions tagged [scjp]

SCJP is a certification for programmers experienced using the Java programming language. SCJP affirms that the programmer really knows how to code in Java. However the ability to design and implement a complete application is not affirmed by this test (it is affirmed by the second step certification, SCJD).

SCJP (Sun Certified Java Programmer) is a certification for programmers experienced using the Java programming language. Achieving this certification provides clear evidence that a programmer understands the syntax and structure of the Java programming language and knows enough about J2SE system library.

During the test, the programmer needs to solve multiple short programming tasks in a limited time. Unlike the second level (SCJD) test, the SCJP test does not require to implement and demonstrate a complex working application.

285 questions
6
votes
6 answers

java IS-A relationship exam question confusion

From MasterExam: Which statements are true? (Choose all that apply) A. is-a relationship always rely on inheritance B. is-a relationship always rely on instance variables C. is-a relationship always require at least two class types D. is-a…
CodeClimber
  • 4,584
  • 8
  • 46
  • 55
6
votes
3 answers

Java - When is it a compiler error and when is it a runtime exception?

I am currently studying for the SCJP certification using the Sierra and Bates Study Guide and in many of the self tests (mock exam questions) I keep running into the same problem - I can't tell whether a particular error will be at runtime (an…
Michael
  • 63
  • 1
  • 1
  • 3
6
votes
4 answers

Question concerning SCJP-6 exam

While preparing for the SCJP-6 exam I faced with a difficult issue. I can’t find answer by myself. Please, answer for the question and give short comments: abstract class A { // insert code here } public abstract A
abatishchev
  • 98,240
  • 88
  • 296
  • 433
6
votes
1 answer

Which run first? default values for instance variables or Super Constructors?

According to the SCJP6 (Page 507) i found that instance variables are assigned default values before the superclass constructors complete, i tried an example in Debugg mode but i saw that the super contractor runs before instance variables get their…
Tarik
  • 4,961
  • 3
  • 36
  • 67
6
votes
2 answers

java LinkedHashSet

I've been studying for OCJP (former SCJP) and I came across the following example which uses LinkedHashSet: public class Test{ int size; public Test(int s){ this.size = s; } @Override public boolean equals(Object obj)…
Maggie
  • 7,823
  • 7
  • 45
  • 66
6
votes
4 answers

Protected member behavior once it was inherited.

I've got some doubts regarding protected identifier. In the first chapter of Sun Certified Java Programmer Study Guide by K.Sierra I found the following information: "Once the subclass-outside-the-package inherits the protected member, that member…
BartoszMiller
  • 1,245
  • 1
  • 15
  • 24
6
votes
4 answers

What does a bitwise exclusive OR do in Java?

Given: public class Spock { public static void main(String[] args) { Long tail = 2000L; Long distance = 1999L; Long story = 1000L; if ((tail > distance) ^ ((story * 2) == tail)) { …
Eslam Hamdy
  • 7,126
  • 27
  • 105
  • 165
6
votes
4 answers

Why is a boolean expression valid in a case block, when booleans are not supported data types for switches?

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 switch on a boolean, so the following will not compile…
Jimmy
  • 16,123
  • 39
  • 133
  • 213
6
votes
5 answers

Objects eligible for garbage collection

This question was taken from Kathy Sierra SCJP 1.6. How many objects are eligible for garbage collections? According to Kathy Sierra's answer, it is C. That means two objects are eligible for garbage collection. I have given the explanation of the…
user414967
  • 5,225
  • 10
  • 40
  • 61
6
votes
1 answer

Java6, Guava, generics, type inference

I've written an utility method in Java: public static final ImmutableSortedSet REVERSED_TIMEUNITS = ImmutableSortedSet.copyOf( Collections.reverseOrder(), EnumSet.allOf(TimeUnit.class) ); /** * Get the number…
Sebastien Lorber
  • 89,644
  • 67
  • 288
  • 419
5
votes
2 answers

Does wrapper widening beat unboxing?

class Dec26 { public static void main(String[] args) { short a1 = 6; new Dec26().go(a1); new Dec26().go(new Integer(7)); } void go(Short x) { System.out.print("S "); } void go(Long x) { System.out.print("L "); } void go(int…
ziggy
  • 15,677
  • 67
  • 194
  • 287
5
votes
2 answers

Confusion over Java's pass-by-value and immutability

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 pass a variable into a method, you pass a copy of the…
Jimmy
  • 16,123
  • 39
  • 133
  • 213
5
votes
3 answers

Overloading methods with var-args - combined with boxing and widening

When overloading methods that contain parameters that dont match, the JVM will always use the method with the smallest argument that is wider than the parameter. I have confirmed the above with the following two examples: Widening: byte widened to…
ziggy
  • 15,677
  • 67
  • 194
  • 287
5
votes
2 answers

Which declarations are valid?

Select the three correct answers (valid declarations). (a) char a = '\u0061'; (b) char 'a' = 'a'; (c) char \u0061 = 'a'; (d) ch\u0061r a = 'a'; (e) ch'a'r a = 'a'; Answer: (a), (c) and (d) Book: A Programmer's Guide to Java SCJP Certification…
5
votes
5 answers

SCJP: can't widen and then box, but you can box and then widen

I'm studying for the SCJP exam and I ran into an issue I can't really wrap my head around. The book says you can't widen and then box, but you can box and then widen. The example for not being able to box is a method expecting a Long and the method…
Jack
  • 59
  • 3