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

Understanding wait()

I created this silly program to play with wait() public class WaitTest { public static void main(String [] args) { System.out.print("1 "); synchronized(args){ System.out.print("2 "); try { args.wait(); …
andandandand
  • 21,946
  • 60
  • 170
  • 271
0
votes
5 answers

Confusing while block

The following code block gives me a compile time error. while(false) { System.out.println("HI"); } The error says that there is an unreachable statement. BUT the following code compiles boolean b=false; …
Nirmit Dalal
  • 315
  • 5
  • 12
0
votes
1 answer

Should I write OCJP 16 or 1.7?

I am planning to give my OCJP certification exam. But i am confused whether to write 1.6 or 1.7? To be specific , I want to know what are the drawbacks or disadvantages if I write OCJP 1.6 version exam?
Stunner
  • 961
  • 2
  • 19
  • 39
0
votes
1 answer

Java Reference Assigned

class ClassA {} class ClassB extends ClassA {} class ClassC extends ClassA {} and ClassA p0 = new ClassA(); ClassB p1 = new ClassB(); ClassC p2 = new ClassC(); ClassA p3 = new ClassB(); ClassA p4 = new ClassC(); p0 = p1 works But, p1 = p2…
Sameer
  • 425
  • 1
  • 7
  • 15
0
votes
4 answers

Enum Example Explanation

Here is a program taken from the SCJP 6 example. Here, we create a enum with different coffee sizes, and declare a private variable called ounces to get the ounce value part of enumeration. I was not able to understand the use of getLidCode method…
shashi27
  • 189
  • 4
  • 19
0
votes
7 answers

SCJP Object Orientation Issue

I have a problem in understanding Question no.9 from Chapter Object Orientation from the SCJP book by K&B. Question: public class Redwood extends Tree { public static void main (String [] args) { new Redwood ( ) . go ( ) ; } void go ( ) {…
Wizard Sultan
  • 830
  • 7
  • 22
  • 45
0
votes
4 answers

compilation of below statement succeeds why?

As i know that Object is the super most class of all classes in java. But, below code i am not able to understand. please help me out. Object c = new long[4]; Object d = new int[4];
0
votes
1 answer

Why we must handle exception for method not throwing exceptions?

Given public class ToBeTestHandleException{ static class A { void process() throws Exception { throw new Exception(); } } static class B extends A { void process() { System.out.println("B "); } } public…
BenMansourNizar
  • 1,558
  • 4
  • 21
  • 42
0
votes
4 answers

Creating new object with constructor

The following code, when compiled and run gives the output as "alpha subsub". SubSubAlpha(); constructor should add "subsub " to variable s and that should be the output. How come the output is " alpha subsub"? class Alpha { static String s = "…
Prateek Singla
  • 679
  • 2
  • 10
  • 22
0
votes
1 answer

How to precisely identify & work greedy or reluctant quantifiers?

Given: import java.util.regex.*; class Regex2 { public static void main (String args[]) { Pattern p = Pattern.compile(args[0]); Matcher m = p.matcher (args [1]); boolean b = false; while (m. find()) { …
Nilay Panchal
  • 541
  • 6
  • 17
0
votes
1 answer

SCJP with label

Below will be compilation fail due to "label z is missing" but if I just move z: to one step below after o = o + 2 then that will work? What is the logic behind this? public class Breaker { static String o = ""; public static void main(String[]…
Ketan Bhavsar
  • 5,338
  • 9
  • 38
  • 69
0
votes
2 answers

How many objects are eligible for gc

Can You please explain this answer..? As I expected answer C Given: 11. class Snoochy { 12. Boochy booch; 13. public Snoochy() { booch = new Boochy(this); } 14. } 15. 16. class Boochy { 17. Snoochy snooch; 18. public Boochy(Snoochy s) { snooch =…
Tez
  • 83
  • 1
  • 9
0
votes
2 answers

How the exists() method of class File works?

Good Morning, i have used these method to check if a certain file exists in a group of directories: public static boolean doesFileExist(String[] directories, String fileName) { String path = " "; for (String dir : directories) { path…
Eslam Hamdy
  • 7,126
  • 27
  • 105
  • 165
0
votes
2 answers

why it's NOT safe to replace a StringBuffer object with a StringBuilder in java version earlier than 1.5

Good evening, i read these statement in a blog it's NOT safe to replace a StringBuffer object with a StringBuilder in java version earlier than 1.5 and it seems to be a fact, but there's no apparent reason for that !!, i know that StringBuffer is…
Eslam Hamdy
  • 7,126
  • 27
  • 105
  • 165
0
votes
1 answer

SCJP subSet() has to be casted to (TreeSet)

I found a curious SCJP question that at first looks as if it was answered correctly: TreeSet s = new TreeSet(); TreeSet subs = new TreeSet(); for(int i = 606; i < 613; i++) if(i%2 == 0) s.add(i); subs =…
luigi7up
  • 5,779
  • 2
  • 48
  • 58