0
Q:

public abstract class Shape {

private int x;

private int y;

public abstract void draw();

public void setAnchor(int x, int y) {

this.x = x;

this.y = y;

}

}

Which two classes use the Shape class correctly?

A) public class Circle implements Shape { private int radius; B) public abstract class Circle extends Shape { private int radius; }
C) public class Circle extends Shape { private int radius; public void draw(); D) None

Answer:   B) public abstract class Circle extends Shape { private int radius; }



Explanation:

Only B is true

Subject: Java
Q:

What is anonymous class?

Answer

Anonymous class is class without name.


EX:


class A {


}


class Demo {


    A r = new A() {


        }; //anonymous class


}


 

Report Error

View answer Workspace Report Error Discuss

Subject: Java

0 1656
Q:

What is local class?

Answer

Local class is class defined inside method


EX;


class A { // top level class


  public static void main(string[] args) {


   class B { // local class


   }


}


}

Report Error

View answer Workspace Report Error Discuss

Subject: Java

0 1757
Q:

what is non-static member class?

Answer

Non-static member class is a class defined inside outer class with out static modifier.


EX:


class A { // top level class or outer class


    ......


    class B { //non-static member class


    }


    .....


}

Report Error

View answer Workspace Report Error Discuss

Subject: Java

0 1616
Q:

What is static member class?

Answer

Static member class is a class defined inside outer class with static modifier.


EX:


Class A {  //top level class or outer class


    .....


    static class B {  //static member class


    }


   .....


}

Report Error

View answer Workspace Report Error Discuss

Subject: Java

0 1815
Q:

What is top level class?

Answer

Top level class is also called outer class. It is not defined inside any class.


Ex:


class A {  //top level class


 


}

Report Error

View answer Workspace Report Error Discuss

Subject: Java

0 1682
Q:

How many types of classes are there in Java?

Answer

Two types of classes:


1) Top Level Class


2) Classes within Class


       i) member classes


             a) static member class


             b) non static member class


      ii) local classes


      iii) anonymous classes

Report Error

View answer Workspace Report Error Discuss

Subject: Java

0 1697
Q:

What is the purpose of the wait(), notify(), and notifyAll() methods ?

Answer

The wait(), notify(), and notifyAll() methods are used to provide an efficient way for threads to wait for a shared resource. When a thread executes an object's wait() method, it enters the waiting state. It only enters the ready state after another thread invokes the object's notify() or notifyAll() methods..

Report Error

View answer Workspace Report Error Discuss

Subject: Java

0 1720
Q:

What are wrapped classes ?

Answer

Wrapped classes are classes that allow primitive types to be accessed as objects.

Report Error

View answer Workspace Report Error Discuss

Subject: Java

0 1736