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
2 answers

How can this code cause deadlock?

While passing SCJP6 exam simulator I found question like this: class Clerk implements Runnable { private Record A, B; public Clerk(Record a, Record b) { A = a; B = b; } public void run() { while(true) { …
Dmitry Zaytsev
  • 23,650
  • 14
  • 92
  • 146
0
votes
3 answers

Why new StringBuffer(new StringBuilder("foo")) does work?

I'm studying for the SCJP certificate and while playing with the StringBuilder and StringBuffer API's I found some situations I can't understand what is happening there. Here is my example code: StringBuffer sb1 = new StringBuffer("sb1"); …
enTropy
  • 621
  • 4
  • 14
0
votes
3 answers

java legal identifiers

I'm readind an eBook that sais: int :b; int e#; are not legal identifiers, but I don't understand why ":" and "#" are not legal tokens. Do you have any idea?
bouhmid_tun
  • 344
  • 1
  • 4
  • 17
0
votes
1 answer

why this SCJP program gives output 21 but I am getting 20?

public class Stepper { enum Roman {I,V,X,L,C,M} public static void main(String... args) { int x=7; int z=2; Roman r = Roman.X; do { switch(r) { case C : r = Roman.L;break; case X : r =…
0
votes
1 answer

Why invokes the constructor the overriden method instead of the one from his class?

By runnung the following code I got the result: method from class A method from class B. public class Test { static class A { public A() { someMethod(); } public void someMethod() { …
Adnan Alicic
  • 29
  • 1
  • 4
0
votes
4 answers

Studying for SCJP, and how to move from knowledge to the application of knowledge

I've read a lot of the SCJP questions here, and all the tips and tricks from Sun and the Head First publishers, and I wonder if I am missing something. I'm having trouble moving from knowledge about a component of Java to being able to answer a…
user4903
-1
votes
1 answer

Confusion with StringBuilder in java

Why is StringBuilder gives me an updated string when i use append but not when i use subString. Following is an example :- class Hello{ public void doSomething(){ StringBuilder sb = new…
Amit
  • 633
  • 6
  • 13
-1
votes
2 answers

Formatters in java

%b, %c, %d, %f, %s How does this work in java? I have been trying to read Formatter class and formattable interface however, I am unable to understand in regards to the conversions passed as arguments. For example: System.out.printf("%f not equals…
user2046417
-1
votes
4 answers

How float with 'e' will work in a variable declaration

public class TypeConversion3 { public static void main(String[] args) { float f = 12e-1F; final long l = 12L; f = f + l; System.out.println(f); //prints 13.2 } } No idea how it prints the value 13.2. I some…
kittu
  • 6,662
  • 21
  • 91
  • 185
-1
votes
3 answers

Why int value must be initlize in first case mentioned below?

I have two different cases where I have used boolean in if condition. Why I need to initialize variable p in CASE 1? CASE 1: public static void main(String[] args) { int p; if(Boolean.TRUE){ p=100; } …
Balkrushn
  • 91
  • 1
  • 1
  • 12
-1
votes
5 answers

Confusion regarding hashset, hashmap, hashcode, equals

Property of SET is it doesnt allow duplicate elements . but referring to SCJP: When hashset or linkedhashset is used. when you add objects you must override hashcode else you may end up with duplicate elements in the set. boolean[] b=new…
-1
votes
1 answer

Can a class have a "IS A Relationship" with itself?

class A { } class B extend A { int i; int j; } Can a class have an IS-A Relationship with itself? In this question, B is an A, right? But can class B have an IS-A relationship with class B?
Amit2311
  • 93
  • 1
  • 7
-1
votes
4 answers

Generic Classes

Place code into the class so that it compiles & generates the out put answer=42 Note:Code options may be used more than once. This question is from SCJP , I have posted answer. I can't understand why they used public Gen (T object){this.object =…
user2985842
  • 437
  • 9
  • 24
-1
votes
3 answers

Shadowing variables in methods

I was reading the certification book of Java 6. And there was an example about "Shadowing variables": package scjp; class Class1 { int number = 28; } public class Example { Class1 myClass = new Class1(); void changeNumber( Class1…
CristianC
  • 15
  • 1
  • 6
-1
votes
2 answers

How sorting is happening here and comparison between cap's and small letters?

public class BioDiesel { public static void main(String args[]) { LinkedList list = new LinkedList(); list.add("BbB1"); list.add("bBb2"); list.add("bbB3"); …
1 2 3
18
19