Juicy multiple choice questions quiz in java.

View previous topic View next topic Go down

Juicy multiple choice questions quiz in java.

Post by BIT0112-Rokon on Tue Jan 03, 2012 7:53 pm

Juicy multiple choice questions quiz in java.

Instruction:
1. The quiz has 20 questions. 19 multiple choice questions and 1 text answer question.
2. Each multiple choice question has only one possible answer.
3. This Quiz Contest is targeted 3rd batch BIT. But anybody can try it.
4. The first three people who send accurate answers at the earliest are rewarded.
5. To send your answers, send an email to anm_brr@live.com in the format 1)i, 2)ii, 3)iii ……. 19)v, 20) (text answer)
6. If you want offline version, click here

Your time starts now!!!!

1. The correct hierarchy of inheritance (in descending order of parenthood) is
a) Java.lang.Throwable
b) Java.lang.Object
c) Java.lang.Exception
d) Java.lang.RuntimeExcpetion


i). a>b>c>d
ii). b>a>d>c
iii). c>d>a>b
iv) b>a>c>d

2. The extension of the binary output created by a Java program is?
i) .java
ii) .class
iii) .exe
iv) .obj

3.
public class ClassA {
public int a;
private int b;
protected final int c = 4;
static final int d = 2;
}

for(int i=0; i<100; i++)
new ClassA();
Hint: Class occupies 8 bytes extra space for storing metadata.

How many bytes of space are allocated in RAM?
i) 2000
ii) 2004
iii) 2008
iv) 2012

4. Which of the statements given bellow is false?
i) Interface variables must be static.
ii) Only public and abstract modifiers are allowed for methods in interfaces.
iii) It is always necessary to create an object implementation for an interface.
iv) You can mark an interface as final.

5. In a java class, what happens when you try to access an object that does not exist?
i) NoSuchObjectFound
ii) NullPointerException
iii) NullReferenceException
iv) NoSuchMethodExcetion
v) NoSuchFieldException

6. Find which one is not true in java
i) Primitives are passed by value and objects are passed by reference.
ii) Classes, methods and variables can be declared as final.
iii) Synchronized methods can be accessed by only one thread concurrently for an instance.
iv) All variables can be declared as transient.

7. while(false){
System.out.println("Hello world");
}Results:
i) IllegalStateException
ii) RuntimeExceptoin
iii) Compilation Error
iv) No error.

8. Which one is not true for java main method?
i) Java main methods are called by JVM
ii) Java application programs must have a main() method.
iii) public static void main(String...args){}
iv) static public void main(String[] args){}
v) main() can not be declared as final.

9. What is true for String and Stringbuffer?
i) String is faster than StringBuffer.
ii) b. String is mutable and StringBuffer is Immutable object
iii) c. Both of them are mutable
iv) d. String is immutable and StringBuffer is mutable
10. Which one is not true for List?

i) ArrayList is good whenever you don’t have thread safety and add/remove/access objects at end and middle of collection.
ii) List allows insert duplicate elements
iii) List allows to insert null object
iv) The initial size for ArrayList is 10 and increase its capacity by double when it reaches maximum(10)

11. Read the code given bellow:
public class ClassA {
int a = 0;

public static void main(String[] args) {
System.out.println(new ClassA().a);
}
} Output:
i) Compiler error
ii) An exception is thrown
iii) The output is 0;
iv) An ambiguous text is printed.

12. When you call System.gc() and Runtime.gc() methods from your program, immediately Garbage collector is called and memory gets free.
i) True
ii) False

13. public static void main(String[] args) {
int x = 5;

try {
x = x * 4;
if (true) {
System.exit(0);
}
} catch (Exception e) {
x = x - 4;
} finally {
x++;
}
System.out.println(x);
} Output of the program:
i) 20
ii) 16
iii) 17
iv) Nothing
v) RuntimeException

14. Which of the following statements is not true?
i) Java is a pure object oriented programming language.
ii) Java is a platform independent language
iii) Java runs on virtual machine
iv) Java comes with the philosophy, write once and run everywhere

15. Output of the following program is
int i = 0;
i = i++;
i = i++;
i = i++;
i = i++;
System.out.println("The value of i is " + i);
i) 4
ii) 5
iii) 0
iv) 3
Output of the following program is
int x = 0;

16. if (x == -x) {
x = x--;
} else {
x++;
}
System.out.println("value of x: " + x);
value of x: ?
i) -1
ii) 1
iii) 0

17. Output of the following program:
public class MyClass {
private int value = 10;

public void setValue(int value) {
this.value = value;
}

public int getValue() {
return value;
}

public static void main(String[] args) {
MyClass a, b, c;
a = new MyClass();
b = a;
a.setValue(20);
c = b;
b.setValue(40);
a = c;
c.setValue(30);
System.out.println(a.getValue() + " " + b.getValue() + " "
+ c.getValue());
}
}

Output:
i) 20,40,30
ii) 10,20,40
iii) 30,30,30
iv) 10,10,10

18. StringIndexOutOfBoundsException is -
i) Checked exception
ii) unchecked exception

19. Finally is the block of code that executes always even if exception is occurred.
i) True
ii) False

20. What is bean in java?? Hints : A vegetable rich in vitamins(Razz )

_________________________________________________________________


Code Explosion Blog | Code Explosion Wiki | The Rokonoid | নির্ঝরিণী

BIT0112-Rokon
Programmer
Programmer

Course(s) :
  • BIT

Blood Group : O+
Posts : 673
Points : 1269

View user profile http://blog.codexplo.org

Back to top Go down

Re: Juicy multiple choice questions quiz in java.

Post by BIT0322-Hira on Thu Jan 05, 2012 3:23 pm

Would you please help me to understand,what is metadata?

BIT0322-Hira
Alpha Release
Alpha Release

Course(s) :
  • BIT

Blood Group : O+
Posts : 24
Points : 33

View user profile

Back to top Go down

Re: Juicy multiple choice questions quiz in java.

Post by BIT0322-Hira on Thu Jan 05, 2012 4:59 pm

All variables can be declared as transient. What does it mean?

BIT0322-Hira
Alpha Release
Alpha Release

Course(s) :
  • BIT

Blood Group : O+
Posts : 24
Points : 33

View user profile

Back to top Go down

Re: Juicy multiple choice questions quiz in java.

Post by BIT0112-Rokon on Fri Jan 06, 2012 6:09 am

did you search over internet ?? Try and help yourself. Its a test. I will discuss all these someday. But before, try to find out, think, search over internet, try in IDE.


_________________________________________________________________


Code Explosion Blog | Code Explosion Wiki | The Rokonoid | নির্ঝরিণী

BIT0112-Rokon
Programmer
Programmer

Course(s) :
  • BIT

Blood Group : O+
Posts : 673
Points : 1269

View user profile http://blog.codexplo.org

Back to top Go down

Re: Juicy multiple choice questions quiz in java.

Post by Sponsored content Today at 11:24 pm


Sponsored content


Back to top Go down

View previous topic View next topic Back to top


 
Permissions in this forum:
You cannot reply to topics in this forum