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
0
votes
4 answers

HashMap is not adding duplicate keys

import java.util.*; class U { int x; U(int x) { this.x = x; } } public class G { public U a = new U(22); public U b = new U(23); Integer y = 22; Integer r = 23; void a() { Map set = new…
user2985842
  • 437
  • 9
  • 24
0
votes
2 answers

Java Certification: How to override methods that define a throws exception?

Can anyone confirm the following in regards to methods that define exceptions thrown when method overriding? I want to be sure I understand it clearly. Given the following code: class A { public void doStuff() throws…
Salsero69
  • 2,160
  • 3
  • 23
  • 27
0
votes
2 answers

Multidimensional array declaration

Which one is valid statement? int[] x =new int[0]{}; new int[2]; int[] x=new int[][]{{1}}[0]; int[][] x = new int[]{0}[0][0]; int x= new int[2]{}[]; The correct answer is 3, and I can understand why it's not 1, 2 or 5, but I don't understand 3 or…
user2985842
  • 437
  • 9
  • 24
0
votes
2 answers

Iterator interface SCJP

import java.util.Collections; import java.util.Iterator; import java.util.LinkedList; import java.util.List; public class TryMe { public static void main(String args[]) { List list = new LinkedList(); …
user2985842
  • 437
  • 9
  • 24
0
votes
3 answers

Scjp Threads in loop

public class B { private int x; public void foo() { int current = x; x = current + 1; } public void go() { for(int i = 0; i < 5; i++) { new Thread() { …
user2985842
  • 437
  • 9
  • 24
0
votes
3 answers

Scjp subclass throwing IOException

class A { public void process() { System.out.print("A,"); } } public class B extends A { public void process() throws IOException { //LINE 23 super.process(); …
user2985842
  • 437
  • 9
  • 24
0
votes
2 answers

inner/outer class SCJP

Which three code fragments, added individually at line 26, produce the output 100? (Choose three.) class Inner { private int x; public void setX(int x) {this.x = x;} public int getX(){return x;} } class Outer{ private Inner y; public void…
user2985842
  • 437
  • 9
  • 24
0
votes
2 answers

scjp: class casting rules set

can we down cast super class if sub class belonngs to same hierarchy ? example : class Building { } public class Barn extends Building { public static void main(String[] args) { Building build1 = new Building(); Barn barn1 = new Barn(); //Barn…
user3066920
  • 31
  • 1
  • 8
0
votes
2 answers

class declaration with generics java

class a{} class b extends a{} class c extends b{} public class d { public static void main(String[] args) { c n = new c(); } } I am reading SCJP. I didn't get the concept of generic class with class and…
user2985842
  • 437
  • 9
  • 24
0
votes
1 answer

SCJP6 var arg issue from Kathie siera

please help me to sort out the issues.because my answer getting different from Kathie siera book answer.for the below code i get compile error because of redeclaration to sifter(BB . But in the book answer is "-434" class AA{} class BB extends…
jai
  • 547
  • 7
  • 20
0
votes
1 answer

proctected variable inside a protected class

Im trying to declare a protected variable inside a protected class but get an error, protected class Car { protected int x = 9; } The valid modifier for the class is public, abstract and final as per Eclipse. Can someone please explain?
user1050619
  • 19,822
  • 85
  • 237
  • 413
0
votes
3 answers

two threads one synchronize method scjp

Why is the answer to this letter b? (question and answer below) I understand 7a 7b 8a 8b, since the method is synchronized hence only one thread could execute at a time, but why is 6a 7a 6b 7b acceptable as well? shouldn't the second thread wait for…
mel3kings
  • 8,857
  • 3
  • 60
  • 68
0
votes
4 answers

Why can't I handle Exception e with try / catch clause?

When I compile the following code everything goes fine and output is as expected: class Propogate { public static void main(String[] args) { Propogate obj = new Propogate(); try { obj.reverse(""); } catch…
paniclater
  • 903
  • 1
  • 12
  • 18
0
votes
1 answer

If I have several Strings formatted differently do I need a separate instance of DateFormat to parse each String?

I am trying to learn the ins and outs of DateFormat's parse() and format() methods for the SCJP 6 exam. I recently tried to make some code to format and parse dates and found that the parse method only works if a String is formatted in the way that…
paniclater
  • 903
  • 1
  • 12
  • 18
0
votes
5 answers

Checked Exception overrides java

When my Master class throws a checked exception , shouldn't the override method should also implement the checked exception?? class Master{ String doFileStuff() throws FileNotFoundException{ return "a"; } } public class test extends…
user1050619
  • 19,822
  • 85
  • 237
  • 413