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 method overriding and overloading?

Answer

Overriding is a method with the same name and arguments as in a parent, whereas overloading is the same method name but different arguments

Report Error

View answer Workspace Report Error Discuss

Subject: Java

0 1598
Q:

If a method is declared as protected, where may the method be accessed?

Answer

A protected method may only be accessed by classes or interfaces of the same package or by subclasses of the class in which it is declared.

Report Error

View answer Workspace Report Error Discuss

Subject: Java

0 2250
Q:

What do you understand by private, protected and public?

Answer

These are accessibility modifiers. Private is the most restrictive, while public is the least restrictive. There is no real difference between protected and the default type (also known as package protected) within the context of the same package, however the protected keyword allows visibility to a derived class in a different package.

Report Error

View answer Workspace Report Error Discuss

Subject: Java

0 1580
Q:

I don't want my class to be inherited by any other class. What should i do?

Answer

You should declared your class as final. But you can't define your class as final, if it is an abstract class. A class declared as final can't be extended by any other class.

Report Error

View answer Workspace Report Error Discuss

Subject: Java

2 5908
Q:

What is the impact of declaring a method as final?

Answer

A method declared as final can't be overridden. A sub-class can't have the same method signature with a different implementation.

Report Error

View answer Workspace Report Error Discuss

Subject: Java

0 1496
Q:

What is a package?

Answer

Package is a collection of related classes and interfaces. package declaration should be first statement in a java class.

Report Error

View answer Workspace Report Error Discuss

Subject: Java

1 1574
Q:

What is difference between Path and Classpath?

Answer

Path and Classpath are operating system level environment variales. Path is used define where the system can find the executables(.exe) files and classpath is used to specify the location .class files.

Report Error

View answer Workspace Report Error Discuss

Subject: Java

0 1688
Q:

What is Thread ?

Answer

A thread is a lightweight subprocess, a smallest unit of processing. It is a separate path of execution. It shares the memory area of process.



As shown in the above figure, thread is executed inside the process. There is context-switching between the threads. There can be multiple processes inside the OS and one process can have multiple threads.

Report Error

View answer Workspace Report Error Discuss

Subject: Java

0 1628