Java Test-1

5 Questions | Attempts: 142
Share

SettingsSettingsSettings
Java Quizzes & Trivia

Basic java questions


Questions and Answers
  • 1. 

    Is Java a pure object oriented language?

    • A.

      Yes

    • B.

      No

    Correct Answer
    B. No
    Explanation
    Java contains in-built support for primitive data types such as int,float etc. Not everything is a object unlike pure object oriented languages such as Ruby etc.

    Rate this question:

  • 2. 

    Public class A{    public void method(){       System.out.println("in A");    }   public static void main(String[] args){        A a = new B();        System.out.println(a.method());   }}class B extends A{    public void method(){        System.out.println("in B");     } }What is the output of the above program?

    • A.

      Compile time error

    • B.

      Run time error

    • C.

      In B

    • D.

      In A

    Correct Answer
    C. In B
    Explanation
    This is a basic class based polymorphism where the sub class overrides the super class's method.

    Rate this question:

  • 3. 

    Every class in java extends the

    Correct Answer
    java.lang.Object
    Object
  • 4. 

    The public static void main method is the          point for your application.

    Correct Answer
    entry
    exit
  • 5. 

    Public class Execution{ static { System.out.println("in static"); } { System.out.println("in init block"); } public Execution(){ System.out.println("in constructor"); } public static void main(String[] args){ Execution e = new Execution(); }}

    • A.

      In static in init block in constructor

    • B.

      In static in constructor in init block

    • C.

      In constructor in init block in static

    • D.

      In constructor in static in init block

    • E.

      Compile time error

    Correct Answer
    A. In static in init block in constructor

Quiz Review Timeline +

Our quizzes are rigorously reviewed, monitored and continuously updated by our expert board to maintain accuracy, relevance, and timeliness.

  • Current Version
  • Jan 16, 2013
    Quiz Edited by
    ProProfs Editorial Team
  • Jul 03, 2010
    Quiz Created by
    Agent_hunt
Back to Top Back to top
Advertisement
×

Wait!
Here's an interesting quiz for you.

We have other quizzes matching your interest.