Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

scjp model questions  RSS feed

hansika motwani
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 )

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

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



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

17)which of the following are illegal loop constructs ?
a.while (int i >0)
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 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){
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 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

26)which of the following represents legal flow control statements
c.continue outer ;
d.continue (inner );
e.return ;
f.exit ();
Abhi vijay
Ranch Hand
Posts: 509
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.


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
Posts: 608
Eclipse IDE Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
1)False,it is not an 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..
10)False,Java will only provide a constructor if you have not typed one yourself.
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
24)Don't know
25)Don't know
26)A C E
Treimin Clark
Ranch Hand
Posts: 757
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hansika, you must do your own HomeWork.
Jesper de Jong
Java Cowboy
Posts: 16007
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
hansika motwani
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
its from balagruswamys book ..
a primer edition
balaguruswamy (core java book)
Vinod Kumar Kommineni
Ranch Hand
Posts: 54
Firefox Browser
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
Amit Ghorpade
Posts: 2856
Fedora Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"vinodkumar k" please check your private messages for an important administrative matter. You can see them by clicking the My Private Messages link above.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!