JAVA QUESTION

Let me tease u a little bit!! Below is a quite familiar java prog. :


public class MyDraft {

public static void main(String[] args) {
System.out.println("Hello World!");
System.out.println("Welcome to Java!");
MyDraft obj = new MyDraft();
System.out.println("Bye Bye!");
}
}



Now the ques. is : Can u do some familiar coding inside MyDraft class but outside the main() method i.e. u must not modify the main() method at all, so that the above prog. gives the output as: All are JavaGuru!


Hint: you have to think of a way such that the main() method doesn't get executed & only "All are JavaGuru!" gets printed in the output.


ANS. It is mentioned in the comments

good link for books

books


for SCJP 1.5

java info :

diff b/w scjp 1.4 and scjp 1.5

Good books


for java :

1. the complete reference
2.core java
3.thinking in java

for scjp :

1.khalid mughal
2.katherine etc..

Objectives of SCJP

You can visit these links to know about the objectives of the exam

SCJP 1.4 :

http://www.sun.com/training/catalog/courses/CX-310-035.xml

SCP 5.0(SCJP 1.5)

http://www.sun.com/training/catalog/courses/CX-310-055.xml

gud sites for SCJP

bill brogden site :http://www.wbrogden.com/

mock exam simulator :http://www.jchq.net/phezam/login.php

mock exam :http://www.akgupta.com/Java/mock_exam.htm

marcus green site :http://www.jchq.net/

list of SCJP links :http://www.wbrogden.com/books/javaexamcram/javacertlist.html

prometric site ( the exam conduting site):
https://www.register.prometric.com/

A good SCJP site

This site has got mock tests for SCJP

http://www.danchisholm.net/

format of the paper

You will find three types of questions on this examination:
* Multiple-Choice Questions with a Single-Correct Answer
* Multiple-Choice Questions with Multiple-Correct Answers
* Fill-In Questions Requiring your Typed Response.

HOW TO APPLY FOR SCJP

Obtain an exam voucher from Sun Educational Services, local office.
Once you obtain the voucher, it can then be redeemed by signing up for the
test at Prometric which is done by making an appointment for specific
date and time. The voucher cannot be refunded back for your money, but it can be transferred. You must complete your exam within one calendar year of your paid registration date or your funds will be forfeited.

SCJP books

* One of the most popular (and recommended) books is: SCJP Sun Certified Programmer for Java 5 Study Guide by Katherine Sierra and Bert Bates (K&B). The publisher is McGraw Hill Osborne Media -- ISBN 0072253606.

* Check the JavaRanch Bunkhouse for additional recommendations and reviews.

Notes Of All The Different Versions of SCJP

SCJP 1.5:

* Dave Allen's notes (html)
* Dave Allen's notes (Yahoo briefcase, downloadable, printable Word format)
* Mikalai Zaikin's SCJP Tiger notes
* XyzWS.COM's SCJP study notes

SCJP 1.4:

* Jane Griscti's notes
* Manish Hatwalne's notes
* Whizlabs tutorials

SCJP 1.2:

* Ashraf Fouad's notes
* Carl's notes
* Heather MacKenzie's notes (Editor's Note: These might actually be for 1.1.)
* Manish Hatwalne's notes
* Velmurugan's notes

Various Versions:

* JDiscuss
* www.xyzws.com

Mock SCJP exams

SCJP 1.5:

* eXamulator: 62 questions in total: http://www.examulator.com/phezam/login.php
* JavaBeat: 2 exams with 25 questions in total: http://www.javabeat.net/javabeat/scjp5/mocks/index.php
* WhizLabs Free Demo (3.94MB Download): http://www.whizlabs.com/scjp/scjp-5.0-details.html
* eJavaGuru.com: 1 quiz on Enums : http://www.ejavaguru.com/scjp5freemockexam.php

Various versions

* JavaRanch List of MockExams
* Maha Anna's list of mock exams
* XyzWS.com's list of mock exams


Look at my new dumps section
DUMPS Are all here

How to Prepare for SCJP* Familiarize yourself with Sun's exam process, including objectives, registration, testing, etc. See Sun's SCJP page for detai

* Familiarize yourself with Sun's exam process, including objectives, registration, testing, etc. See Sun's SCJP page for details.
* If you are new to Java programming, start with a good introductory book such as Head First Java or Thinking in Java. Check the JavaRanch Bunkhouse for additional recommendations and reviews. Refer to the API documentation and the Java Language Specifications along the way.
* Once you have a foundation, study at least one good (and current) certification preparation book. (
* Use the SCJP forum to post questions, and reinforce your own understanding by answering other people's questions.
* Take as many mock exams as possible. Use these to determine where additional study is needed, and as a guide to when you are ready.

What is new in exam for SCJP 1.5

* Exam objectives: Several important new language features have been added, including enums, generics, static imports, and autoboxing/unboxing. API features added to the exam include java.lang.StringBuilder, java.util.Locale, java.util.Formater, java.util.Scanner. java.util.regex.Pattern, and java.util.regex.Matcher. Java IO features have been added, including File, BufferedReader, BufferedWriter, FileReader, FileWriter and PrintWriter. Concepts such as loose coupling and high cohesion have been added, as well as greater emphasis on encapsulation as it relates to JavaBean conventions. Bit manipulation (e.g., shifting) has been dropped.
* Number of questions: 72 (increased from 61)
* Time: 175 minutes (increased from 120 minutes)
* Passing score: 59% (increased from 52%)
* Level of difficulty: The concensus is that it is more difficult.
* Format of questions: As before, you will always be told how many options to choose. No credit is given for partial answers.

Java Dumps 2

These are java tutorials by A.K.Gupta

http://www.akgupta.com/Java/notes.htm

Java Dumps

See this site it has got lots of stuff for SCJP

http://www.javaranch.com/gramps/SCJPLinks.jsp

Points to Remember

• Everything from the start marker of a comment block (e.g. /*)

is ignored until the first occurrence of the matching end marker (*/).

• The "throw" statement can only throw "Throwable" objects.

A NullPointerException will be thrown if the Exception given to the

"throw" statement results in null.

• In the same statement you can use decimal, octal and/or hexadecimal statements.

• While creating a multidimensional array, dimensions must be

created left to right. So, int [] [] array = new int [] [4]; is not valid.

• Elements of an un-initialized array object get the default value

corresponding to the type of the elements. Whether the array object

reference is a local or member variable, does not matter.

• In a switch statement the type of the case labels must be assignable to

the type of switch expression.

• It is not possible to break out of an "if" statement. If the "if" statement is placed

within a labeled block, a switch statement or a loop construct, the usage of "break"

would be valid.

• The "if" statement does not return any value.

• "continue" cannot be used outside the context of a loop.

• A variable declared in a "try" block is not visible in "catch" or "finally" block.

• If C extends B and B extends A, then it is not possible to call a method of A

( implemented in all the three classes ) from an instance method in class C.

• An object that has been eligible for garbage collection may stop being

eligible for garbage collection and return to normal life. This happens

if the call to the finalize() reestablishes a reference from the active part

of the program to the object.

• If a class has a final blank variable, then it must be initialized when an

instance is created ( in all the constructors or any initializer ) , or else

the code will fail to compile.

• A thread's status (user or daemon) can be changed before the thread

is started. Changing the status of a thread already started throws

IllegalStateException.

INSTANCE OF WORKS

We had a test last Sunday on Operators

Where we got to know that instanceof cannot be assigned

to Boolean values.

But this code snippet works fine when you compile in Java 1.5

class instanceofdemo

{ public static void main(String[] args)

{ Parent obj2 = new Child();

boolean a=obj1 instanceof Parent;

System.out.println("obj1 instanceof Parent: "+a);


 

}}

class Parent{}

class Child extends Parent implements MyInterface{}

interface MyInterface{}

Blogger Just Made Easier

Now You can post on your blog through WORD 2007

It has a feature publishing your post and asks for

The account(Here it is Blogger)

And also asks for your Username and Password

And instantly u can publish your docs from blogger

Java Test3


 


 

Question 1

class SRC102 {

public static void main (String[] args)

{

int i1 = Math.round(0.5f);

int i2 = Math.round(1.5d);

System.out.print(i1 + "," + i2);

}}

What is the result of attempting to compile

and run the program?

a.     Prints: 0,1

b.     Prints: 0,2

c.     Prints: 1,1

d.     Prints: 1,2

e.     Compile-time error

f.     Run-time error

g.     None of the above


 


 

Question 2

class A {

public static void main (String args[]) {

byte primitiveByte = 1; // 1

Byte b1 = new Byte(primitiveByte); // 2

Byte b2 = new Byte(1); // 3

System.out.print(b1.byteValue() + b2.byteValue());

}}

What is the result of attempting to compile

and run the program?

a.     Prints: 2

b.     Prints: 11

c.     Compile-time error at 1

d.     Compile-time error at 2

e.     Compile-time error at 3

f.     Run-time error

g.     None of the above


 

Question 3

class A {

public static void main(String[] args) {

Boolean b1 = new Boolean(true); // 1

Boolean b2 = new Boolean(false); // 2

Boolean b3 = new Boolean(TRUE); // 3

Boolean b4 = new Boolean(FALSE); // 4

Boolean b5 = new Boolean("TrUe"); // 5

Boolean b6 = new Boolean("fAlSe"); // 6

}}

Compile-time errors are generated

at which lines?

a.     1

b.     2

c.     3

d.     4

e.     5

f.     6


 


 

Question 4

class SRC103 {

public static void main (String[] args) {

int i1 = Math.round(0.5f);

int i2 = Math.round(1.5f);

System.out.print(i1 + "," + i2);

}}

What is the result of attempting to compile

and run the program?

a.     Prints: 0,1

b.     Prints: 0,2

c.     Prints: 1,1

d.     Prints: 1,2

e.     Compile-time error

f.     Run-time error

g.     None of the above


 


 

Question 5

class MWC102 {

public static void main (String[] args) {

String s1 = "ABCDE";

System.out.print(s1.substring(1,2)+s1.substring(3));

}}

What is the result of attempting to compile

and run the program?

a.     Prints: AABC

b.     Prints: ACDE

c.     Prints: ABABC

d.     Prints: ABCDE

e.     Prints: BABCD

f.     Prints: BDE

g.     Prints: BCABCD

h.     Prints: BCDE

i.     Compile-time error

j.     Run-time error

k.     None of the above


 


 

Question 6

Which of the following are not methods of the java.lang.String class?

a.     append

b.     concat

c.     delete

d.     insert

e.     replace

f.     substring

g.     valueOf

Util Package

Q1:

What is the Collections API?

A:

The Collections API is a set of classes and interfaces

that support operations on collections of objects.





2:

What is the List interface?



A:

The List interface provides support for ordered

collections of objects.









Q3:

What is the Vector class?

A:

The Vector class provides the capability

to implement a growable array of objects.



Q4:

What is an Iterator interface?

A:

The Iterator interface is used to step

through the elements of a Collection .





Q5:

Which java.util classes and interfaces support

event handling?

A:

The EventObject class and the

EventListener interface support event processing.



Q6:

What is the GregorianCalendar class?

A:

The GregorianCalendar provides

support for traditional Western calendars



Q7:

What is the Locale class?

A:

The Locale class is used to tailor

program output to the conventions of a

particular geographic, political, or cultural region .


Q8:

What is the SimpleTimeZone class?

A:

The SimpleTimeZone class provides

support for a Gregorian calendar .



Q9:

What is the Map interface?

A:

The Map interface replaces the JDK 1.1

Dictionary class and is used associate keys with values.




Q10:

What is the highest-level event class of the

event-delegation model?

A:

The java.util.EventObject class is the h

ighest-level class in the event-delegation

class hierarchy.



Q11:

What is the Collection interface?

A:

The Collection interface provides support

for the implementation of a mathematical bag -

an unordered collection of objects

that may contain duplicates.



Q12:

What is the Set interface?

A:

The Set interface provides methods for

accessing the elements of a finite mathematical set.

Sets do not allow duplicate elements.


Q13:

What is the typical use of Hashtable?

A:

Whenever a program wants to store a

key value pair, one can use Hashtable.



Q14:

I am trying to store an object using a key

in a Hashtable.And some other object

already exists in that location, then what

will happen? The existing object will be

overwritten? Or the new object will be stored elsewhere?

A:

The existing object will be overwritten and thus

it will be lost.



Q15:

What is the difference between the size and capacity

of a Vector?

A:

The size is the number of elements actually

stored in the vector, while capacity is the

maximum number of elements it can store at a

given instance of time.



Q16:

Can a vector contain heterogenous objects?

A:

Yes a Vector can contain heterogenous objects.

Because a Vector stores everything in terms of Object.



Q17:

Can a ArrayList contain heterogenous objects?

A:

Yes a ArrayList can contain heterogenous objects.

Because a ArrayList stores everything in terms of Object.



Q18:

What is an enumeration?

A:

An enumeration is an interface containing methods for

accessing the underlying data structure from which the

enumeration is obtained. It is a construct which collection

classes return when you request a collection of all the

objects stored in the collection. It allows sequential access

to all the elements stored in the collection.


Q19:

Considering the basic properties of Vector and ArrayList,

where will you use Vector and where will you use ArrayList?

A:

The basic difference between a Vector and an ArrayList is

that, vector is synchronized while ArrayList is not. Thus

whenever there is a possibility of multiple threads accessing

the same instance, one should use Vector. While if not

multiple threads are going to access the same instance

then use ArrayList. Non synchronized data structure

will give better performance than the synchronized one.



Q20:

Can a vector contain heterogenous objects?

A:

Yes a Vector can contain heterogenous objects.

Because a Vector stores everything in terms of Object.





How To Create Javapath

My friends have problems with setting the CLASSPATH

so to set the classpath we follow the following steps

  1. we open the notepad
  2. we add the following data

set PATH=%path%;E:\program files\java\jdk1.6.0_01\bin;
set CLASSPATH=.;E:\program files\java\jdk1.6.0_01\lib;.;E:\java files\jchart2d-2.0.0.jar;
set JAVA_HOME=E:\program files\java\jdk1.6.0_01;

3. we save it as a .BAT file

my java was installed in E:\program files\java\jdk1.6.0_01\

if your java is in any other folder just replace this by the path where your java

files have been stored.

u must be thinking wat is jchart2d-2.0.0.jar

jchart2d is a java charting library and is used for dynamic charting