File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Tips,oneliner Just before the SCJP Exam

 
N Mukherjee
Ranch Hand
Posts: 141
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi friends,
Here goes an idea to contribute as well as learn at the same time.
For friends who are facing this Exam in short notice might
get some benifit by simply browsing through this Thread(I know
One such thread has been in vogue for quite some time!).
Here goes my contribution:
************************************************************
1.No append() for String class.
2.concat() for String and append() for StringBuffer do the same.
They glue two strings together.......(watch out for more...)....correct me please ...nm
 
N Mukherjee
Ranch Hand
Posts: 141
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi again,
Here goes a list:
3.Math class constructor is private;So it cannot be called.
4.All Exceptions are subclasses of a class called "java.lang.Throwable".
5.CheckedExceptions must be caught/ or, rethrown.
6.abstract method can not be (a) final (b)static or (c)private.
7.final class can have -->static methods
But cannot have-->abstract methods.
8."Threading" and "Garbage Collection" are platform dependent.
More to come.......corrections if any...most welcome.....Thanks......nm
 
Prasanna Joshi
Greenhorn
Posts: 11
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

AWT : MenuItem extends MenuComponent extends Object
Exceptions :
The Object thrown by a throw statement must be assignable to the Throwable type.This includes the Error and Exception types.
Basics :
The "goto" and "const" are keywords which are reserved by Java
"true" and "false" are technically boolean literals
"null" is technically a null literal.
IO :
InputStream and OutputStream are byte Oriented
Reader and Writer classes are character Oriented

[This message has been edited by Prasanna Joshi (edited July 05, 2000).]
 
Paul Smiley
Ranch Hand
Posts: 244
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
2.concat() for String and append() for StringBuffer do the same.
They glue two strings together.......(watch out for more...)....correct me please ...nm

Be careful here! You need to know this for the exam. You must know that concat() creates a new string and doesn't append to the current/existing one; StringBuffer just builds on the same object. This is VERY important for questions on Strings and StringBuffers using '.equals()' or '=='...

[This message has been edited by Paul Smiley (edited July 05, 2000).]
 
snafu man
Greenhorn
Posts: 2
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
nan'na bhai, esab ki, ami kicchhui bujhte parcchhi na
 
N Mukherjee
Ranch Hand
Posts: 141
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Paul,
I have some more......
(*)strictfp is a Keyword.
(*)finally{} block in Exception Handling always executed even if we use break
The only exception being System.exit(0).
***************
Looking for corrections and contributions from friends specially JavaGuru....
***************
[This message has been edited by N Mukherjee (edited July 06, 2000).]
 
Anonymous
Ranch Hand
Posts: 18944
  • 0
  • send pies
  • Quote
  • Report post to moderator
NM,
could you please give some more details for cheched & unchecked exceptions.
Thanks in advance,
DS
 
ricky gonzalez
Ranch Hand
Posts: 167
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry, but what does strictfp do? I didn't see that any where.
Thanks.
 
N Mukherjee
Ranch Hand
Posts: 141
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Deepak, Ricky,
Well strictfp is to make certain floating point computation faster for
processors like "Pentium".
USE:strictfp class AnyClass{
//write anything
}
for more of "strictfp" just search within this forum.
Exception could be checked or Runtime type. Former includes IOException,FileNotFoundException,InterruptedException
Runtime or UncheckedExceptions are ArithmaticException,NullPointerException and
NumberFormatException etc...Hope this will help......Thanks...nm
 
Anonymous
Ranch Hand
Posts: 18944
  • 0
  • send pies
  • Quote
  • Report post to moderator
tips for equals:
object equals() shallow compare, ref == ref
string equals() deap compare, value eq value
stringbuffer equals() shallow compare
tips for length:
array x.length
string x.length()
stringbuffer x.length()
all primative reference, conversion, & casts are determined at compile time.
all object referenced (including interfaces and arrays) conversion are detemined at compile time. casting is split between compile and runtime.
Monty6
 
Paul Smiley
Ranch Hand
Posts: 244
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
(*)finally{} block in Exception Handling always executed even if we use break The only exception being System.exit(0).
Well- almost! There are other instances, like an OutOfMemory error where the whole program dies, but that probably won't be on the test...
 
Jim Yingst
Wanderer
Sheriff
Posts: 18671
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
...or if you turn off your computer before it completes execution...
 
N Mukherjee
Ranch Hand
Posts: 141
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Everybody,
Let us discuss some more*************
1.Valid switch arguments are byte, int, short, char only.
2.No access specifier to a class implies it is "friendly"(By default).
3.int a[][], int[]a[] or int [][]a all three are valid expressions.
4.constructors can not be native, abstract, static, synchronized or final.
5.int i=019//ILLEGAL (Guess why?)
6.byte b=10b;char c=17c;short myshort=99S//ALL are invalid
Special Thanks to Marcus Green for his nice tutorial.It was simply too good.
Thanks once again.
Looking for corrections and additions specially from Paul and others......nm
 
Paul Smiley
Ranch Hand
Posts: 244
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
...or, if you cross the international time line in a boat at 12:00 GMT precisely and your PC is struck by lightning during the catch statement execution...
Sorry, I had to do it...
 
Madhav Lakkapragada
Ranch Hand
Posts: 5040
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

A link to one such post we all contributed when we were in the heat of the preparation....contains a lot of must see oneliners..
enjoy
Regds.
- satya
 
Paul McKenna
Ugly Redneck
Ranch Hand
Posts: 1006
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please could someone tell me how much the SJCP tests the following areas:
Network Programming
java.util (Set,List,Map)
 
Anonymous
Ranch Hand
Posts: 18944
  • 0
  • send pies
  • Quote
  • Report post to moderator
NM, & other JAVAgurus....
could u please provide some tips for IO(java.io package) also.this is one area which covers more than 4-5 questions in SCJP.i think we should start discussing it also...
thanks in advance
DS
 
Marcela Blei
Ranch Hand
Posts: 477
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by N Mukherjee:
5.int i=019//ILLEGAL (Guess why?)


At first I didn�t think this was illegal, I compiled it and I got a: malformed integer number error and still didn�t known why. But when it tried to convert the number to the decimal format I discover that a 9 could�t be in an octal literal. It�s a simple and good question!
 
N Mukherjee
Ranch Hand
Posts: 141
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi everbody,
Some more from my side:
1.using File class, one cannot change current directory
2.constructors can be private, protected,public.
3.Top level class can have three modifiers-public , abstract and final.
4.Static methods can be overloaded.But no overridding.
5.a=b=c=0//legal
6.note:"!7"//illegal...guess why???simple!!
Thanks for all of your kind participation.
Bye
 
Deepak M
Ranch Hand
Posts: 124
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by N Mukherjee:
3.Top level class can have three modifiers-public , abstract and final.
4.Static methods can be overloaded.But no overridding.
Bye

Correction !.....
Top-level class can have FOUR modifiers, the above and strictfp
Static methods are HIDDEN. Instance methods are overridden.
Hiding is similiar to overriding the only difference being its only for static methods and fields and member types !
 
shankar changayil
Greenhorn
Posts: 4
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Static methods according to the below example can be overridden!!
class Test
{
static void show()
{
System.out.println("Show method in Test class");
}
}
public class Q2 extends Test
{
static void show()
{
System.out.println("Show method in Q2 class");
}
public static void main(String[] args)
{
Test t = new Test();
t.show();
Q2 q = new Q2();
q.show();
t = q;
t.show();
q =(Q2)t;
q.show();
}
}
 
Anonymous
Ranch Hand
Posts: 18944
  • 0
  • send pies
  • Quote
  • Report post to moderator
Yeah, static methods can be overriden but "polymorphism will not take place".
 
Anonymous
Ranch Hand
Posts: 18944
  • 0
  • send pies
  • Quote
  • Report post to moderator
hi,
My contributions.
1) one can extend only from one class but implement may interfaces
2)Interfaces can be public or default only the methods are public by default even when no access specifiers are specified
ex
public interface i{
void main();
}
class x implements i{
//void main(){}// compiler complains should be public
public main(){} // works
}
3) Wrapper classes override equals method, the File class also overrides the equals() method
4). Integer i=new Integer(5);
i.equals(new Long(5)); returns false not a compile time error
more later
Regds.
Rahul.
[This message has been edited by rahul_mkar (edited July 26, 2000).]
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic