Questions tagged [ocpjp]

OCPJP (Oracle Certified Professional, Java Programmer), formerly Sun Certified Java Programmer (SCJP), is a certification for programmers experienced using the Java programming language. Achieving this certification provides clear evidence that a programmer understands the basic syntax and structure of the Java programming language.

http://education.oracle.com/pls/web_prod-plq-dad/db_pages.getpage?page_id=320&p_org_id=28&lang=US

80 questions
0
votes
2 answers

Java Comparator Interface

I have a misunderstanding about Comparator interface and its method compare here is the following code and i am wondering why compare method return -33 i believe that it should return 33 import java.util.*; public class Sorted implements…
user2780962
  • 113
  • 2
  • 3
  • 10
0
votes
1 answer

OCPJP 8 What is a Symbolic link using NIO2

I am trying to get Java 8 certification i already have Java 6 a long time ago and Java 7 is my weak point because i havent work with it i am a little confuse. What is a symbolic Link?? According to wikipedia. In computing, a symbolic link (also…
chiperortiz
  • 4,751
  • 9
  • 45
  • 79
0
votes
0 answers

TreeSet.tailSet returns SortedSet, said to be updatable vice versa but not when i code

I am trying to understand TreeSet.tailSet it was easy to implement but I am confused about the documentation : public SortedSet tailSet(E fromElement) Description copied from interface: NavigableSet Returns a view of the portion of this set…
mark ortiz
  • 659
  • 1
  • 6
  • 13
0
votes
1 answer

setMaximumDigits method of NumberFormat class

Please justify the output for the below code. Code: import java.text.NumberFormat; import java.text.ParseException; public class Number_format_Demo { /** * @param args * @throws ParseException */ public static void main(String[] args) throws…
0
votes
2 answers

pass var jfrom JS to PHP

In my code the $vl var is empty. Why? JS; PHP: document.write(vl); "; echo "bariabile: ".$vl; ?>
Flex_able
  • 35
  • 6
0
votes
2 answers

objects in String constant pool in java

public class NewClass { public String makinStrings() { String s = "Fred"; s = s + "47"; s = s.substring(2, 5); s = s.toUpperCase(); return s.toString(); } } How many objects are created in the above…
user4277706
0
votes
1 answer

Multi threading instance field implementation

public class Chicks { synchronized void yacks(long id) { for(int x = 1; x<3; x++) { System.out.println(id + " "); Thread.yield(); } } } class ChickYacks implements Runnable { Chicks c;…
user4414924
0
votes
2 answers

java - Overriding with covariant types wrt variables

class G { int x = 5; } class H extends G { int x = 6; } public class CovariantTest { public G getObject() { System.out.println("g"); return new G(); } public static void main(String[] args) { …
rpg
  • 1
  • 3
0
votes
5 answers

Java: ToString() prints the same hashcode each time

class Point { private int xPos, yPos; public Point(int x, int y) { xPos = x; yPos = y; } public static void main(String[] args) { System.out.println(new Point(10,20)); } } The output of above code…
sk89
  • 51
  • 1
  • 9
0
votes
2 answers

Executing stored procedure from Java, other than with JDBC CallableStatement

I am preparing the Java 7 certification using one of the mock test suites available. One of the test questions I stumbled upon is about the JDBC CallableStatement class, and one of the correct answers (according to the tool) is: A CallableStatement…
NotSoOldNick
  • 555
  • 4
  • 11
0
votes
2 answers

There's a conceptual error in Java String method

Here I was training to my OCP and test some String behaviors. And when i get this: System.out.println("a".substring(0) == "a".substring(0)); // true System.out.println("a".substring(0) == "aa".substring(1)); // false Some doubts came to…
0
votes
3 answers

Is there any book for upgrade to java se 7 programmer certification exam?

I need help. I want to appear for upgrade to java se 7 programmer certification exam. While searching on net, I found this.. Oracle Tutorial for upgrade to java se 7 certification Is there any book for the same? Thanks
bsm
  • 1,793
  • 11
  • 30
  • 41
0
votes
2 answers

Java: Does an endless loop eventually lead to a StackOverflowError?

I'm currently reviewing for my OCPJP 6 using the Sierra & Bates reviewer. I stumbled upon a question regarding an endless loop not throwing a StackOverflowError. As far as I've learned, it should throw it eventually. Please refer to this PDF for the…
mpmp
  • 2,409
  • 4
  • 33
  • 46
0
votes
7 answers

Can you please explain this Thread working?

Heres the code about threads.....I dont know the difference between those 2 new() statements. Runnable r=new Runnable() { public void run() { System.out.print("Cat"); } }; Thread t=new Thread(r) { public void run() { …
Ajinkya
  • 147
  • 1
  • 2
  • 11
0
votes
7 answers

Can somebody please explain me this output of polymorphism?

Heres the code : class A{ int data=10; void show1(){ System.out.println("In A="+data); } } class B extends A{ int data=20; void show2(){ System.out.println("In B="+data); } } public class Overriding4 { …
Ajinkya
  • 147
  • 1
  • 2
  • 11