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
18
votes
7 answers

Java unreachable catch block compiler error

Why in Java can we catch an Exception even if it is not thrown, but we can't catch it's subclass (except for "unchecked" RuntimeExceptions and it subclasses). Example code: class Test { public static void main(String[] args) { try { …
bary
  • 1,699
  • 2
  • 15
  • 24
18
votes
5 answers

What's this generics usage in Java? X.method()

I've read the whole SCJP6 book Sierra and Bates book, scored 88% the exam. But still, i never heard of how this kind of code works as it's not explained in the generics chapter: Collections.reverseOrder() What is this kind of generics…
Sebastien Lorber
  • 89,644
  • 67
  • 288
  • 419
17
votes
8 answers

How long should I prepare for SCJP?

Ok I know this might sound a bit silly, as it depends on the person, but on average how much time should I spend on preparing for SCJP? I already have some experience with Java (a few small and medium projects for my university, from implementing a…
Zenzen
  • 227
  • 1
  • 2
  • 3
14
votes
2 answers

Java Inheritance issue

While exploring for scjp questions, I came across this behaviour which I found strange. I have declared two classes Item and Bolt as follows: class Item { int cost = 20; public int getCost() { return cost; } } class Bolt…
santosh-patil
  • 1,540
  • 1
  • 15
  • 29
14
votes
4 answers

Are SCJP 6 and OCJP both same?

Are both SCJP 6 and OCJP 6 exams same? I am going to write OCJP 6 exam this month end but I am preparing SCJP 6 book by Kathy Seirra. And for practice I am preparing Kathy seirra's "OCP Java SE 6 programmer study guide". is it ok? I am confusing…
Raju Boddupalli
  • 1,789
  • 4
  • 21
  • 29
13
votes
4 answers

Why is the output like this?

class Another { public void method(Object o) { System.out.println("This is in method which takes object"); } public void method(String s) { System.out.println("This is method which takes string"); } } public class…
Chetan
  • 1,590
  • 3
  • 19
  • 34
12
votes
3 answers

What does redefining static methods mean in Java?

I've been reading a section on Statics in the SCJP study guide, and it mentions the following : static methods can't be overridden, but they can be redefined What does redefining actually mean? Is it a case of having a static method that exists…
Jimmy
  • 16,123
  • 39
  • 133
  • 213
12
votes
4 answers

Priority queue ordering of elements

How come the elements of priority queue are ordered according to natural order by default as it doesn't implement comparable interface. From the docs, it says elements are ordered based on natural ordering but I can't find anywhere it talks about…
kittu
  • 6,662
  • 21
  • 91
  • 185
12
votes
5 answers

Getting confused with == and = in "if" statement

I know that we cant use assignment operator in if statements in java as we use in any other few languages. that is int a; if(a = 1) { } will give a compilation error. but the following code works fine, how? …
GuruKulki
  • 25,776
  • 50
  • 140
  • 201
12
votes
6 answers

Slight confusion regarding overriding where variables are concerned

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 enough. This is the question : class A { int x =…
Jimmy
  • 16,123
  • 39
  • 133
  • 213
12
votes
3 answers

ClassCastException because of classloaders?

While playing with classloaders i got the following exception: Exception in thread "main" java.lang.ClassCastException: xxx.Singleton cannot be cast to xxx.Singleton Does this mean that an instance from a classloader is not castable to an class of…
Sebastien Lorber
  • 89,644
  • 67
  • 288
  • 419
10
votes
3 answers

Hidden fields though inheritance

In the following code example: class Parent { int x =5; public Integer aMethod(){ System.out.print("Parent.aMthod "); return x; } } class Child extends Parent { int x =6; public Integer aMethod(){ …
ziggy
  • 15,677
  • 67
  • 194
  • 287
9
votes
5 answers

Why is this code not thread safe?

In code snippet below, declaring the doThings() method as static would make the class thread-safe. Is the reason for this that if multiple TestSeven threads are started and since x is a static variable a race condition could occur ? public class…
blue-sky
  • 51,962
  • 152
  • 427
  • 752
9
votes
2 answers

Confused over initialisation of instance variables

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 getInt() { return k+1; } public static void…
Jimmy
  • 16,123
  • 39
  • 133
  • 213
9
votes
3 answers

What are the Changes to sun SCJP/SCJA/SCEA tracks since oracle took over?

The Context: It appears that the simple scjp ->scja->.... tracks for sun certification have been merged with other oracle style certifications... As a developer, I've spent some time lately trying to figure out the new "pathways" for…
jayunit100
  • 17,388
  • 22
  • 92
  • 167
1
2
3
18 19