Curioustab
Aptitude
General Knowledge
Verbal Reasoning
Computer Science
Interview
Aptitude
General Knowledge
Verbal Reasoning
Computer Science
Interview
Home
»
Java Programming
»
Declarations and Access Control
Which of the following is/are legal method declarations? protected abstract void m1(); static final void m1(){} synchronized public final void m1() {} private native void m1();
1 and 3
2 and 4
1 only
All of them are legal declarations.
Correct Answer:
All of them are legal declarations.
Explanation:
All the given statements are legal declarations.
← Previous Question
Next Question→
More Questions from
Declarations and Access Control
Which two of the following are legal declarations for nonnested classes and interfaces? final abstract class Test {} public static interface Test {} final public class Test {} protected abstract class Test {} protected interface Test {} abstract public class Test {}
Which three are valid method signatures in an interface? private int getArea(); public float getVol(float x); public void main(String [] args); public static void main(String [] args); boolean setFlag(Boolean [] test);
Which three form part of correct array declarations? public int a [ ] static int [ ] a public [ ] int a private int a [3] private int [3] a [ ] public final int [ ] a
Which two cause a compiler error? float[ ] f = new float(3); float f2[ ] = new float[ ]; float[ ]f1 = new float[3]; float f3[ ] = new float[3]; float f5[ ] = {1.0f, 2.0f, 2.0f};
You want a class to have access to members of another class in the same package. Which is the most restrictive access that accomplishes this objective?
What is the prototype of the default constructor? public class Test { }
Which cause a compiler error?
Which two code fragments will compile? interface Base2 implements Base {} abstract class Class2 extends Base { public boolean m1(){ return true; }} abstract class Class2 implements Base {} abstract class Class2 implements Base { public boolean m1(){ return (7 > 4); }} abstract class Class2 implements Base { protected boolean m1(){ return (5 > 7) }} interface Base { boolean m1 (); byte m2(short s); }
You want subclasses in any package to have access to members of a superclass. Which is the most restrictive access that accomplishes this objective?
Which one creates an instance of an array?
Discussion & Comments
No comments yet. Be the first to comment!
Name:
Comment:
Post Comment
Join Discussion
Discussion & Comments