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:

If you are using C language to implement the heterogeneous linked list, what pointer type will you use?

Answer

The heterogeneous linked list contains different data types in its nodes and we need a link, pointer to connect them. It is not possible to use ordinary pointers for this. So we go for void pointer. Void pointer is capable of storing pointer to any type as it is a generic pointer type.

Report Error

View answer Workspace Report Error Discuss

Subject: Java

0 7864
Q:

Which of the following modifiers can be used with Local inner class?

A) Final or Abstract B) Final or Transcient
C) Abstract or Transcient D) Final or public
 
Answer & Explanation Answer: A) Final or Abstract

Explanation:

It can either be Final or Abstract

Report Error

View Answer Report Error Discuss

Filed Under: Java

0 2600
Q:

A lock can be acquired on a class.

The above statement is

A) True B) False
C) Both A and B D) None
 
Answer & Explanation Answer: A) True

Explanation:

A lock can be acquired on a class. This lock is acquired on the class's Class object.

Report Error

View Answer Report Error Discuss

Filed Under: Java

0 12285
Q:

Convert the expression ((A + B) * C – (D – E) ^ (F + G)) to equivalent  Postfix notations.

A) AC + B * DE - FG +^- B) AB + C * DE - FG + ^-
C) AC + B* DE - FG -+ ^ D) AB + C * DE - FG -+ ^
 
Answer & Explanation Answer: B) AB + C * DE - FG + ^-

Explanation:
Report Error

View Answer Report Error Discuss

Filed Under: Java

4 4112
Q:

What are the various elements of OOPS?

Answer

Various elements of OOP are:


• Object


• Class


• Method


• Encapsulation


• Information Hiding


• Inheritance


• Polymorphism

Report Error

View answer Workspace Report Error Discuss

Subject: Java

0 1642
Q:

try { int x = Integer.parseInt("two"); }

Which could be used to create an appropriate catch block?

A) ClassCastException B) IllegalStateException
C) NumberFormatException D) None
 
Answer & Explanation Answer: C) NumberFormatException

Explanation:

C is correct. 'Integer.parseInt' can throw a NumberFormatException, and IllegalArgumentException is its superclass 

Report Error

View Answer Report Error Discuss

Filed Under: Java

3 27642
Q:

class Hell {

public static void main(String[] args) {

Integer i = 42;

String s = (i<40)?"life":(i>50)?"base":"ball";

System.out.println(s);

}

}

A) null B) ball
C) base D) None
 
Answer & Explanation Answer: B) ball

Explanation:

D is correct. This is a ternary nested in a ternary with a little unboxing thrown in.Both of the ternary expressions are false.

Report Error

View Answer Report Error Discuss

Filed Under: Java

1 32011
Q:

Which method names follow the JavaBeans standard?

A) addSize B) putDimensions
C) getCust D) deleteRep
 
Answer & Explanation Answer: C) getCust

Explanation:

C use the valid prefixes 'get' and 'is

Report Error

View Answer Report Error Discuss

Filed Under: Java

0 7454