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 the difference between path and classpath?

Answer

Path contains path of .exe files(commands).


Classpath contains path of packages. packages can be stored in folder or .jar files

Report Error

View answer Workspace Report Error Discuss

Subject: Java

0 1798
Q:

What is JAR file? what are the main uses of JAR files?

Answer

JAR files are java's version of ZIP files. In fact, JAR uses the ZIP file format.


uses:


- to compress a number of . class files into one file


- to make a java executable JAR file.

Report Error

View answer Workspace Report Error Discuss

Subject: Java

0 1533
Q:

What is unwrapping?

Answer

Unwrapping is also called as unpacking or unboxing.


Getting the private data stored in the object by using methods is called unpacking or unwrapping.

Report Error

View answer Workspace Report Error Discuss

Subject: Java

0 1913
Q:

What is wrapping?

Answer

Wrapping is also called as packing or boxing.


Storing the data inside the object as private data which can accessed outside the class only by using methods.


 

Report Error

View answer Workspace Report Error Discuss

Subject: Java

0 1976
Q:

What is different among String, StringBuffer, StringBuilder?

Answer

String class objects are immutable objects and they represents strings( sequence of characters)


StringBuffer class objects are mutable objects representing strings and they are Thread safe


StringBuild class objects are also mutable objects representing strings and they are not Thread safe

Report Error

View answer Workspace Report Error Discuss

Subject: Java

0 1644
Q:

How to call argument constructor?

Answer

new ClassName( arg1, arg2, .... argN);


Ex:


Class sample {


   Sample(int a) {


   System.out.println("arg con a =" +a);


   }


}


class Demo {


    Public static void main( String[] args) {


     Sample s1= new Sample(23);


     Sample s2= new Sample(45);


    }


}

Report Error

View answer Workspace Report Error Discuss

Subject: Java

0 1671
Q:

What is Constructor?

Answer

Constructor is not a special method.


Constructor is block of code that is executed automatically whenever object of the class is created.

Report Error

View answer Workspace Report Error Discuss

Subject: Java

0 1690
Q:

What is difference between methods and blocks?

Answer

Method contains name, parameters, return type and executable body. But block does not contains name, parameters, return type.It contains only executable body.


Methods are executed by method call statements. Blocks are executed automatically with class loading and with object creation.

Report Error

View answer Workspace Report Error Discuss

Subject: Java

0 1942