JAVA Technical Interview Question & Answers

1.Which method can access to private attributes of a class? Ans. Only instances of the same class 2.What is the value of ‘number’ afte...

1.Which method can access to private attributes of a class?
Ans.Only instances of the same class

2.What is the value of ‘number’ after the following code fragment execution? 
int number = 0;
int number2 = 12
while (number < number2)
{
number = number +1;
}

Ans. 12

3.Which Can be Passed as ana argument to a function?
Ans. Constant

4.What is a JVM?
Ans.Java Virtual Machine

5.What is the base class of all classes?
Ans. java.lang.Object

6.A static function is
Ans. Can be called using the class name and function name

7.The new operator Can
Ans.Obtains memory for a new variable

8.Which is a reserved word in the Java programming language?
Ans. native

9.Which is a valid keyword in java?
Ans. interface

10.What is the numerical range of a char?
Ans. 0 to 65535

11.What is the technical definition of the language that includes the syntax and semantics.
Ans. Java language specification

12.What is the prototype of the default constructor?
Ans.public Test( )

13.What is a software unit that combines a structured set of data with a set of operations for inspecting and manipulating that data.
Ans. Object

14.Which is used to convert the one type value to another.
Ans. Casting

15.Which method cannot be overridden?
Ans.Final

16.Which Modifier Can be accessed only to classes in the same package.
Ans.Default modifier

17.What is the name of the method used to start a thread execution?
Ans. start();

18.Which package has the ability to analyze itself at runtime
Ans.java.lang.reflect

19.Collection of classes and interfaces that provides a high-level layer of access protection and name space management is? 
Ans.Package

20.Interfaces with no methods are called as
Ans. Marker Interface

21.To determine the width and height of an application which method is used?
Ans. getSize()

22.What are the applet’s lifecycle methods?
Ans. init(), start(),paint(), stop() and destroy()

23.The default layout out of a JPanel is
Ans.FlowLayout

24.Which method Should be override to draw things on a Swing component
Ans. paintComponent()

25.Which method on a condition should you invoke to wake all waiting thread?
Ans.Comdition .signalAll()

26.Which Method to is used to Force one thread to wait for another thread to finish.
Ans.join()

27.Which of the following will directly stop the execution of a Thread?
Ans. wait()

28.Predict The output Of the Following

      class PassA 
{
    public static void main(String [] args) 
    {
        PassA p = new PassA();
        p.start();
    }

    void start() 
    {
        long [] a1 = {3,4,5};
        long [] a2 = fix(a1);
        System.out.print(a1[0] + a1[1] + a1[2] + " ");
        System.out.println(a2[0] + a2[1] + a2[2]);
    }

    long [] fix(long [] a3) 
    {
        a3[1] = 7;
        return a3;
    }
}

Ans. 15 15

29.Which interface does java.util.Hashtable implement?
Ans. Java.util.Map

30.Which cannot directly cause a thread to stop executing?
Ans.Calling the notify method on object

31.What allows the programmer to destroy an object x?
Ans. Only the garbage collection system can destroy an object

32.Which interface should be implemented to listen for a button action event.
Ans.Action listener

33.What will be the output of the program?

      public class X 
{  
    public static void main(String [] args) 
    {
        try 
        {
            badMethod();  
            System.out.print("A");  
        } 
        catch (RuntimeException ex) /* Line 10 */
        { 
            System.out.print("B"); 
        } 
        catch (Exception ex1) 
        { 
            System.out.print("C"); 
        } 
        finally 
        {
            System.out.print("D"); 
        } 
        System.out.print("E"); 
    } 
    public static void badMethod() 
    { 
        throw new RuntimeException(); 
    } 
}

Ans. BDE

34.An application responds to an exception by throwing an another exception is called as
Ans.Chained Exceptions

35.What will be the output of the program?

public class RTExcept 
{
    public static void throwit () 
    {
        System.out.print("throwit ");
        throw new RuntimeException();
    }
    public static void main(String [] args) 
    {
        try 
        {
            System.out.print("hello ");
            throwit();
        }
        catch (Exception re ) 
        {
            System.out.print("caught ");
        }
        finally 
        {
            System.out.print("finally ");
        }
        System.out.println("after ");
    }
}

Ans.hello throwit caught finally after

36.What is an independent path of execution in a program?
Ans.Thread

37.Which model used in swing component?
Ans.Model view controller

38.A program that a java enabled browser can download and run is a
Ans.Applet

39.Which method is called on calling the repaint method
Ans.update

40.Process of confining paint operations to a limited area or shape is
Ans.clipping

41.Each object is an instance of a class and each class belong to a
Ans.hierarchy

42.What is an instance of a class.
Ans.Object

43.All components from javax.swing are developed in
Ans.pure java

44.What JVM executes
Ans.byte code

45.Which operator is used to refer to the parent object of the currently running object
Ans.super

46.The collection of related classes and interfaces is
Ans.Package

47.Which Class supports constant strings
Ans.String

48.Which Class Supports growable and modifiable strings.
Ans.String Buffer

49.What is the default buffer size used by any buffered class?
Ans.512 bytes

50.Input Stream/Output Stream class is
Ans.byte-oriented

51.Which method returns greater value out of the supplied values
Ans.Math.max()

52.Process of storing the object contain into the file is known as
Ans.serialization

53.An example O.S for platform independence is
Ans.Linux, Solaris, etc

54.When several threads act on object simultaneously and the result is reliable then it is known as 
Ans.synchronized

55.When method defined in subclass which has same signature as a method in a super class, it is known as method
Ans. Overriding

56.Which method is used just before an object is destroyed and can be called just prior to garbage collection.
Ans.finalize()

57.If a thread is to be declared as a daemon thread, it must be declared before
Ans.start method

58.What is byte code in the context of Java?
Ans.The type of code generated by a Java compiler

59.The process of writing the state of an object to a byte stream is
Ans.Serialization

60.The mechanism that ensures that only one thread is accessed the resources at a time is
Ans.Synchronization

61.An object that describes a state change in a source is
Ans.event

62.The problem that arises during the execution of a program is
Ans.exception

63.What are  two Java IDE’s?
Ans.Netbeans, Eclipse, etc.

64.Which contains and controls the layout of components
Ans.Container

65.List some Java keywords(unlike C, C++ keywords)?
Ans.import, super, finally, etc.

66.A program that is executing in known as 
Ans.process

67.Any data that is sent by the client to the server can be called as
Ans.Request

68.java.util.regex consists of which classes?
Ans.Pattern class, Matcher class and PatternSyntaxException class.

69. Which containers may have a MenuBar?
Ans.Frame

70.Smallest individual unit in java program is known as
Ans.token

71.What will be the output of the program?

class Test 
{
    public static void main(String [] args) 
    {
        int x= 0;
        int y= 0;
        for (int z = 0; z < 5; z++) 
        {
            if (( ++x > 2 ) || (++y > 2)) 
            {
                x++;
            }
        }
    System.out.println(x + " " + y);
    }
}

Ans. 8 2

72.Which act as an interface between the java application and the backend database
Ans.Drivers

73.XML stands for
Ans.Extensible Markup Language

74.The instance of a class is the actual object created at
Ans.Run-time

75.The program written in the Java programming language that can be included
in an HTML page, much in the same way an image is included in a page is
Ans.applet

76.Predict The output of the program?

class Bitwise 
{
    public static void main(String [] args) 
    {
        int x = 11 & 9;
        int y = x ^ 3;
        System.out.println( y | 12 );
    }
}

Ans.14

77.A graphical user interface is built of graphical elements called
Ans.Components

78.What is a client side program
Ans.Cookie

79.scope resolution operator denoted by
Ans. ::

80.API stands for
Ans.Application Program Interface



Related

Interview Questions 1423751696211166418

Post a Comment

Follow Us

Hot in week

Recent

Comments

Side Ads

item