Wednesday, 20 May 2015

JAVA BASIC QUESTIONS


1.What gives java it's 'write once and run anywhere' nature? 
 Bytecode

2.____________ allow primitive data types to be accessed as objects 
 Wrapper classes

3.Output of the applet program can be seen by using? 1)applet viewer 2)java enable Web browser 3)command prompt 4)none of these
 1 and 2 

4.Interfaces can use _______ access specifier
 public

5.String is the predefined _____________?
Class                                                                                                                           
6.By default , how many minimum threads are available in program ?
 One

7.The class 'Class' is available in the_______package
 java.lang 

8.The keyword: virtual in Java: 
 Doesn't exist, because all non-static Java methods are virtual by default.

9.A function that defines the steps necessary to instantiate one object of that class is called:
 a constructor.

10.If you want to execute some statement without main method then ________ is used.
 Static block

11.What will be the output of the program?
class PassS
{
 public static void main(String [] args)
 {
 PassS p = new PassS();
p.start();
 }
void start()
 {
 String s1 = "slip";
 String s2 = fix(s1);
System.out.println(s1 + " " + s2);
 }
String fix(String s1)
 {
 s1 = s1 + "stream";
 System.out.print(s1 + " ");
 return "stream";
 }
 }
 slipstream slip stream 

12.The Java Virtual Machine manages its own:
 memory and allocates it as necessary.

13.How many access specifiers in java?
 

14.How many classes we are able to extend in java?
 One

15.Which methods can access to private attributes of a class?
 Only methods those defined in the same class

16.All collection classes are available in ___________ package.
 java.util 

17.What is the value of "d" after this line of code has been executed?
double d = Math.round ( 2.5 + Math.random( ));
 

18.In applet, for accepting user defined parameter, we need to use _________ tag.
 param

19.How can you stop your class from being inherited by another class?
 Add the final access modifier to the class. 

20.Which method executes only once?
 init()

21.Why we need to write static keyword to main method?
 To create single copy 

22.Immutable objects are always...
 thread safe 

23.What is auto boxing?
 JVM conversion between primitive types and reference types. 


Thank You...

No comments:

Post a Comment

Ads Inside Post