JAVA

Questions related to JAVA!!!

1.Which of the following statements is false about objects?
a.An instance of a class is an object
b.Objects can access both static and instance data
c.Object is the super class of all other classes
d.Objects do not permit encapsulation

2.Which methods can access to private attributes of a class?
a.Only Static methods of the same class
b.Only instances of the same class
c.Only methods those defined in the same class
d.Only classes available in the same package.

3.What is an aggregate object?
a.An object with only primitive attributes
b.An instance of a class which has only static methods
c.An instance which has other objects
d.None of the above

4.Assume that File is an abstract class and has toFile() method. ImageFile and BinaryFile are concrete classes of the abstract class File. Also, assume that the method toFile() is implemented in both Binary File and Image File. A File references an ImageFile object in memory and the toFile method is called, which implementation method will be called?
a.Binary File
b.Image File
c.Both File and Binary Files
d.None of the above

5.A class can have many methods with the same name as long as the number of parameters or type of parameters is different. This OOP concept is known as
a.Method
b.Invocating
c.Method
d.Overriding
e.Method Labeling
f.Method
g.Overloading

6.Which of the following is considered as a blue print that defines the variables and methods common to all of its objects of a specific kind?
a.Object
b.Class
c.Method
d.Real data
e.types

7.What are the two parts of a value of type double?
a.Significant Digits,
b.Exponent
c.Length, Denominator
d.Mode, Numerator

8.After the following code fragment, what is the value in fname?
Code:
String str;
int fname;
str = "Foolish boy.";
fname = str.indexOf("fool");
a.2
b.-1
c.4

9.What is the value of ‘number’ after the following code fragment execution?
Code:
int number = 0;
int number2 = 12
while (number < number2)
{
number = number + 1;
}
a.5
b.12
c.21
d.13

10.Given the following code snippet;
Code:
int salaries[ ];
int index = 0;
salaries = new int salaries[4];
while (index < 4)
{
salaries[index] = 10000;
index++;
}
What is the value of salaries [3]?
a.4000
b.5000
c.1500
d.1000

11.Which of the following is not a return type?
a.boolean
b.void
c.public
d.Button

12.If result = 2 + 3 * 5, what is the value and type of ‘result’ variable?
a.17,byte
b.25, byte
c.17, int
d.25, int

13.What is the data type for the number 9.6352?
a.float
b.double
c.Float
d.Double

14.Assume that the value 3929.92 is of type ‘float’. How to assign this value after declaring the variable ‘interest’ of type float?
a.interest = 3929.92
b.interest = (Float)3929.92
c.interest = 3929.92(float)
d.interest = 3929.92f

15. Among the following options, choose the four options that describe the appropriate default values for array elements of the types indicated? 
1. int -> 0 
2. String -> “null” 
3. Dog -> null 
4. char -> ‘\u0000′ 
5. float -> 0.0f 
6.boolean -> true 
A. 1, 2, 3, 4
B. 2, 4, 5, 6
C. 3, 4, 5, 6
D. 1, 3, 4, 5

16. Which option among the following lists only Java programming language keywords?
A. goto, instanceof, native, finally, default, throws
B. byte, break, assert, switch, include
C. try, virtual, throw, final, volatile, transient
D. strictfp, constant, super, implements, do
E. class, if, void, long, Int, continue

17. Which of the following options would legally declare, construct, and initialize an array? 
A. int [] myList = {“1″, “2″, “3″};
B. int myList [] = {4, 3, 7};
C. int [] myList = (5, 8, 2);
D. int myList [] [] = {4,9,7,0};

18. You want subclasses in any package to have access to members of a superclass. Which is the most restrictive access that accomplishes this objective?
 A. private
 B. transient
 C. public
 D. protected

19. interface Base { boolean m1 (); byte m2(short s); } 
1.interface Base2 implements Base {} 
2.abstract class Class2 extends Base { public boolean m1(){ return true; }} 
3.abstract class Class2 implements Base {} 
4.abstract class Class2 implements Base { public boolean m1(){ return (7 > 4); }} 
5.abstract class Class2 implements Base { protected boolean m1(){ return (5 > 7) }} 
A. 3 and 4
B. 1 and 5
C. 1 and 2
D. 2 and 3

20. Among the 6 options provided below, which three form part of correct array declarations?
1.public int a [ ]
2.static int [ ] a
3.public [ ] int a
4.private int a [3]
5.private int [3] a [ ]
6.public final int [ ] a
A. 2, 4, 5
B. 1, 3, 4
C. 2, 5, 6
D. 1, 2, 6

21. Which of the following is/are legal method declarations?
1.protected abstract void m1();
2.static final void m1(){}
3.synchronized public final void m1() {}
4.private native void m1();
A. All of them are legal declarations.
B. 1 and 3
C. 2 and 4
D. 1 only

22. Which three among the following are valid method signatures in an interface? 
1.private int getArea(); 
2.public float getVol(float x); 
3.public void main(String [] args); 
4.public static void main(String [] args); 
5.boolean setFlag(Boolean [] test); 
A. 3, 4, and 5
B. 2 and 4
C. 1 and 2
D. 2, 3 and 5

23. Which option among the following creates an instance of an array?
A. int[ ] ia = new int[15];
B. int ia[ ] [ ] = { 4, 5, 6 }, { 1,2,3 };
C. char[ ] ca = “Some String”;
D. float fa = new float[20];

24. Which of the following class level (nonlocal) variable declarations will not compile?
A. volatile int d;
B. private synchronized int e;
C. protected int a;
D. transient int b = 3;

Comments

  1. there is no link provided for answer
    above link doesn't work
    pls provide a link.

    ReplyDelete
    Replies
    1. Sorry for inconvenience,
      Now, It is working.
      plz check it out.
      Thank you for telling me.

      Delete
  2. How do you remember so much? is this was really asked or these are similar questions to which were asked?Reply

    ReplyDelete
    Replies
    1. Hello,
      These questions were exactly asked by them. Many friends told me about these question so I m shared this with all of u.
      Thank u

      Delete
    2. Okay! these questions are of this year or previous year?

      Delete
    3. Some ques are from 2012 and some ques are from 2013. 5 ques from this yr asked at ILP ahmd..

      Delete

Post a Comment

Do you wanna ask me some thing???

Popular posts from this blog

What is IRA (Initial Readiness Assessment) in TCS

Swapping base locations in TCS

Information Resource Center (IRC) in TCS