File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Some Basic Questions Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Some Basic Questions" Watch "Some Basic Questions" New topic

Some Basic Questions

amit sanghai
Ranch Hand

Joined: Dec 05, 2000
Posts: 231

Q1) State true or false :
protected access is provided even to subclasses that reside in a different package from the class that owns this feature.

Q2) Which of the following are valid method declarations?
a] abstract native void method();
b] abstract void method(){}
c] public static final void method(){}
d] abstract public synchronized void method();
e] public void abstract method();
f] public abstract void method() throws ArithmeticException;

Q3)Which of the following are valid member variable declarations?
a] abstract int i;
b] final int i;
c] final volatile int i;
d] public transient final i
e] protected static final int i
Q4)Which of the following are true regarding interfaces?
a] All methods in an interface are public,abstract and static
b] All interface methods should have public accessibility when implemented in class
c] All variables in an interface are public,static and final
d] interfaces can have constructors
e] It is valid to declare the methods explicitly in an interface as static.

Q5)True or False
a] Default constructor is provided for all classes
b] Default constructor is provided for the class which does define any constructor.
Q6)What would be the possible output?
1.class SampleConstructor
3.public static void main(String args[])
4. {
5. Parent p=new Parent(10);
6. Child c=new Child();
9.class Parent
11. public Parent(int i)
12. {
13. System.out.println("Value of i is "+i);
14. }
16.class Child extends Parent
18. public Child()
19. {
20. System.out.println("Constructor's do not have return type");
21 }
a] compiles and runs with output Constructor's do not have return type
b] compiler error in line 18 prevents compilation
c] compiler error in line 11
d] compiles and runs with output Value of i is10
I am really confused.

Thanks in advance.

21. Which of the following are invalid about constructors
a] constructors do not have return type
b] you cannot have more than one constructor in a class
c] To call a constructor defined in the superclass, you have to place the call as the first statement in the
calling constructor

Madhav Lakkapragada
Ranch Hand

Joined: Jun 03, 2000
Posts: 5040

it is always a good idea to limit the number of qstns in your
post to one (best) or at the most two....
also, pl. go the the FAQ, I am sure most of these are already
answered there and so no one is spending time responding to this

- satya

Take a Minute, Donate an Hour, Change a Life
bill bozeman
Ranch Hand

Joined: Jun 30, 2000
Posts: 1070
Amit, you have done a few posts where you have 10 or more questions in the post. Trust me, people will answer you if you limit each post to one or at most two questions. People find it too confusing and too daunting of a task to answer 10 questions in one post.
Ask these questions again in separate messages and me and many others will clear your doubts.
I agree. Here's the link:
subject: Some Basic Questions
It's not a secret anymore!