aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes scjp model questions Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "scjp model questions" Watch "scjp model questions" New topic
Author

scjp model questions

hansika motwani
Ranch Hand

Joined: Jul 22, 2008
Posts: 44
If possible with explanation(even one line if time wont permit you to write elaborately (please explain so that i can get your way of thinking to the query )

TRUE OR FALSE (T/F) WRITE ANSWERS WITH QUESTION NUMBERS
1)It is an error to have a method with the same
signature in both the superclass and subclass

2)A constructor must always invoke its superclass constructor in its first statement

3)Subclasses of an abstract class that do not provide an implementation of an abstract method are also abstract

4)All methods in abstract class must be declared abstract

5)when the string objects are compared with == ,the result is true if the strings contain the same values

6)A string object cant be modified after it is created

7)A catch can have comma separated multiple arguments

8)It is an error to catch the same type of exception in two different blocks
assosciated with a particular try block
9)A final class may not have any abstract methods

10)java always provides a default constructor to a class

11)when present , package must be the first non comment statement in the file

12)I)The import statement is always the first non comment statement in a java program file
II)int 0xCAFE=2? EXPLAIN


13)I)objects are passed to a method by use of call - by - reference
II)IS -10>>>2=1073741821.EXPLAIN ?

----------------------------------------------------------------------------------------------------------------------------------------------

MULTIPLE CHOICE .CHOOSE A,B,C,D ...
OBSERVE CAREFULLY YOU MAY ALSO FIND MORE THAN ONE ANSWER
THEN WRITE THAT MANY OPTIONS

14)What will be the result of the expression 9|9
a)1b)18c)9d)none of the above

15)consider the following statements
int x=10,y=15;
x=(x<y)?(y+x) y-x);
what will be the value of x after executing the statements

16)which of the following operators are overloaded for string objects
a)-b)+c)+=d)&

17)which of the following are illegal loop constructs ?
a.while (int i >0)
{
i--;
other statements ;
}
b.for (int i=10,int j=0;i+j>5;i=i-2,j++)
{
body of statements
}

18)which of the following contol expressions are valid for an if statement
a.an integer expression
b.a boolean expression
c.either a or b
d.neither a nor b

19) In the following code snippet , which lines of the code contain error
1)int j=0;
2)while (j<10){
3)j++;
4)if (j==5)continue loop ;
5)System.out.println("j is "+j);
}
a.line 2 .b.line 3
c.line 4.d.line 5 e.none of the above

20)which keyword can protect a class in a package from accessibility by the classes outside the package ?
a.private b.protected c.final d.dont use any keyword(default)

21)we would like to make a member of a class visible in all subclasses regardless of what package they are in
which one of the following keywords would achieve this a.private b.protectedc.public d.private protected

22)class class a
{
public static void main(String args[])
{
classb b = classb();
}
classa (int x)
{}
}
class classb extends classa
{}
what will happen when we compile and run this code ?
a.compile and run successfully
b.error classa does not define a no argument constructor
c.error classb does not define a no argument constructor
d.error there is no code in the class classb
e.error there is nod code in the constructor classa (int x)


23)what does the following line of code do ?
TextField text = new TextField (10);
a.creates text object that can hold 10 rows of text
b.creates text object that can hold 10 columns of text
c.creates the object text and initializes it with the value 10
d.The code is illegal


24)what is java_g used for
a.using the jdb tool
b.executing a class with optimization turned off
c.To provide information about deprecated methods
d. none of the above

25)which of the following command lines options generates documentation for all classes and methods
a.-protected.
b.-public
c.-private
d.-verbose
e.-encoding


26)which of the following represents legal flow control statements
a.break;
b.break();
c.continue outer ;
d.continue (inner );
e.return ;
f.exit ();
Abhi vijay
Ranch Hand

Joined: Sep 16, 2008
Posts: 509
1) FALSE- It is possible to have methods with the same signature in the sub and superclass(Overriding).

2) FALSE - It can also invoke this() in the first statement which is a call to other constructor in the same class.

3) TRUE

4) FALSE - Abstract class can also contain methods which are not abstract.

9) TRUE - Final classes can never be subclasses, so abstract methods in final class can never be implemented.

10) FALSE - JAVA provides a default constructor only if the programmer has not declared one. If the programmer has already declared a constructor, then the compiler wont bother to provide a default.
Duran Harris
Ranch Hand

Joined: Nov 09, 2008
Posts: 598

1)False,it is not an error..it is an override
2)False,it may invoke either super() or this() (But not both)
3)Subclasses of an abstract classes that do not provide an implementation HAVE to be abstract otherwise =>compiler error
4)False,an abstract class may have non-abstract methods BUT if one abstract method is included they must ALL be declared abstract.
5)False when Strings are compared with == the result will be true if both strings refer to the same object.
6)True,a string is immutable.Changing it will result in the compiler SECRETLY creating a new string for you(and giving it the same name)
7)I'm not sure..
8)I'm not sure..
9)True
10)False,Java will only provide a constructor if you have not typed one yourself.
11)True
12)False (see Number 11)
13)False objects are passed by copy-of-reference-variable-value.
14)I don't know..
15)25 (see ternary expressions)
16)B C
17)B ( cant declare more than one data type)
18)A B
19)C (loop isn't labelled)
20)A D
21)B
22)B
23)B
24)Don't know
25)Don't know
26)A C E
27)


===>SCJP 1.5(72%)<===
==>SCWCD1.5(76%)<===
Treimin Clark
Ranch Hand

Joined: Nov 12, 2008
Posts: 757
Hansika, you must do your own HomeWork.
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14430
    
  23

On JavaRanch, when you copy questions from a book, mock exam or other source, you are required to quote your sources. So, please tell us where you copied these questions from.


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 8 API documentation
hansika motwani
Ranch Hand

Joined: Jul 22, 2008
Posts: 44
its from balagruswamys book ..
a primer edition
balaguruswamy (core java book)
Vinod Kumar Kommineni
Ranch Hand

Joined: Jun 12, 2008
Posts: 54

Hi Harris i feel that the answers in your post for 5th and 18th question are wrong
5th-i feel its true because there is something called sting constant pool which leads the reference variables to point to same string if both strings are same.
18th-answer is only B because java does not support an integer expression
in place of a boolean expression for control expressions.

Correct me if i am wrong.


Regards
vinod SCJP 6.0
Amit Ghorpade
Bartender

Joined: Jun 06, 2007
Posts: 2718
    
    6

"vinodkumar k" please check your private messages for an important administrative matter. You can see them by clicking the My Private Messages link above.


SCJP, SCWCD.
|Asking Good Questions|
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: scjp model questions