JAVA INTERVIEW QUESTIONS

  1. (OOP) What is a class?
    In OOP terms, a class is a template for creating multiple objects. It defines the state and behavior of the object.
  2. (OOP) What is an Object?
    An instance of a class

    • CricketScorer cricketScorer = new CricketScorer();
    • cricketScorer is an object of the class CrickeScorer.
  3. (OOP) What is state of an object?
    The state of object is the values that it has at that particular point in time.
  4. (OOP -Java) What is the super class of every class in Java.
    • Object.
    • When we create an object it inherits all the methods and properties of the Object class.
  5. (OOP) What is the behavior of an object?
    Methods supported by an object.
  6. (Java Object class) Explain the toString() method.
    Prints the contents of a given object.
  7. (Java Object class)  Explain the equals() method.
    used when we want to compare two objects.
  8. (Java Object class) Show how to implement a derived class of toString() in a class.
    • @Override
    • public String toString(){
    •   return "Animal [name=" + name + ", type=" + type +"]";
    • }
  9. (OOP) Show a simple example of using the extends key word to create a class Hero which inherits from a base class Actor.
    • public class Hero extends Actor {
    •   public void fight(){
    •     System.out.println("fight");
    • };

    }
  10. (General Knowledge) Create a main class in java
    • public static void main(String[] args) {
    •     //Printout a greeting.
    •     System.out.println("Hello World!");
    • }
Author
geschw66
ID
355445
Card Set
JAVA INTERVIEW QUESTIONS
Description
Possible Java interview questions thwarted on the unsuspecting chump job applicant.
Updated