Simple random java interview questions


What is the supermost class of character-based input streams.

a)  InputStream    b)  OutputStream   c) Reader   d)  Writer                        Ans: c
=========================================================================

Which class is used to communicate between threads?
  a) PipedInputStream    b) BufferedInputStream   Ans: a
=========================================================================

What is the superclass of JFrame?

a) java.awt.Container   b)  java.awt.Component  c)  java.awt.swing.JContainer  d) java.awt.Frame    Ans:  d
=========================================================================

What the priority of operators?

nor, and, or, isNull
   
Question comes on the combinations.
=========================================================================

What is the super class of JApplet
a)  java.applet.Applet   b) java.awt.Frame   Ans: a
=========================================================================

Whart is the return type of getParameter() of Applet class.
Ans: String
=========================================================================

What service() method is a method of --------------------------

a) Servlet interface   b) GenericServlet   c)  HttpServlet             Ans: a
=========================================================================

What does ServletContext has info about?

a) user request   b)  user response   c) environment info             Ans: c
=========================================================================
JavaBean syntax:


=========================================================================

start, resume, suspend methods exist in which class

a) Runnable interface   b) Thread  c)  Applet             Ans: b

Note:  1. Runnable interface method:  run() only
           2. Thread methods: start(), sleep(), suspend(), resume() etc.
           3. Object class methods inherited by Thread: wait(), notify(), notifyAll()  
           4. Applet class methods: init(), start(), stop(), destory(), getParameter(), showStatus() etc.
           5. paint() method belongs to java.awt.Component class and is inherited by Frame and Applet.
=========================================================================

getParameter() returns String
getParameterValues() returns String array
getParameterNames() return Enumeration interface
=========================================================================

showStatus() syntax

a) showStatus(String)    b) showStatus(String, int , int)                   Ans: a
=========================================================================

javax components except Container are written in

a) in Java fully   b) partially in Java  c) fully in C   d) partially in C                Ans: a

=========================================================================

Which of the following is not unchecked exception?

a) ArithmeticException   b) RuntimeException  c) InterruptedException     Ans: c
=========================================================================

try
{
  System.out.println("Hai");
}
finally
{
    System.out.println("Hello");
}

Output:  Hai and Hello
=========================================================================

Is this declaration correct?

String s = "My Class";

a)  true  b) false                   Ans: a

0 commentS: