Question Index

In chess, assuming that the columns are numbered A to H and the rows are numbered 1 to 8. Write a program to find whether a black camel gets killed, given that white elephant is at E7, white camel at F3 and white minister at D2. Assume that there is nothing else on the chess board apart from these four.

Input (Black Camel Position) Output (Boolean)
A1 false
B2 true
E2 true
G2 true
H3 false
G5 true
E7 true
C6 true

class WillBlackCamelGetKilled

{    public static void main(String s[])
        ChessPosition blackCamel = new ChessPosition('B', 4);
        System.out.println("Will Black Camel get killed : " + willBlackCamelGetKilled(blackCamel));


public static boolean willBlackCamelGetKilled(ChessPosition blackCamel) {
//Write code here to find whether black camel will get killed
class ChessPosition {

char column;
int row;

public ChessPosition(char column, int row) {
this.column = column;
this.row = row;

public String toString() {
return column + "" + row;



Topic: Behavior Of Java Classes Using Methods

Read this topic
Take test on this topic

Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App