IBM Interview Question for Software Engineer / Developers


Team: ISL
Country: India
Interview Type: In-Person




Comment hidden because of low score. Click to expand.
0
of 0 vote

The Solar System includes the star, planets, natural satellites and artificial satellites. Use the Composite design pattern.

Our galaxy (Milky Way) object that consists of other objects such as our solar system which further contains objects such as the Earth and the Sun. An easy way to describe the Earth to an alien residing in some other galaxy would be:
Milky way - Solar System - Earth

Thus, the Milky Way is a parent object to the Solar System which is itself a parent to the Earth and other planets.

- Anonymous October 02, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

A Planet Class can have properties of Name,Radius, Distance from the SUN in AU. The behaviour can be getters.
The Sun class be defined as a Singleton.
The SolarSystem has composition of Planets and the Sun.

- R@M3$H.N October 02, 2012 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

How about considering the different categories of planets:
1) Terrestrial Planets (Mercury,Venus, Earth, Mars)
2) Gas Giants (Jupiter, Saturn)
3) Ice Giants (Uranus, Neptune)
4) Dwarf Planets (Pluto,Ceres,Eris,Makemake,Haumea)

- Anonymous October 02, 2012 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

Modeling a solar system in Java, besides being fun, is a good exercise to illustrate and practice thinking in terms of some basic concepts in Object Oriented Design (OOD), especially inheritance and polymorphism.

public abstract class GravityObject {
	double xPosition;
	double yPosition;
	double degreeInOrbit;
	double distanceFromParent;

	GravityObject() {
	this.distance = 0;
	}

	GravityObject(double distance) {
	this.distance = distance;
	}
}

import java.util.ArrayList;

public abstract class OrbitalSystem extends GravityObject {
	private ArrayList children = new ArrayList(); // Objects within the system. They will orbit the parent.

	public void add(GravityObject child) { children.add(child); }

	public void tick() {
		for (int x = 0; x < children.size(); x++) {
			GravityObject current = children.get(x);
			current.degree += 1
			current.xPosition = this.xPosition + Math.cos(degree/180 * Math.PI)* current.distance;
			current.yPosition = this.yPosition - Math.sin(degree/180 * Math.PI) * current.distance;
		}
	}
}

public class Star extends OrbitalSystem { 

};

public class Planet extends GravityObject { 

};

public static int main(String[] args) {
	Star s = new Star(); // Create a new star.
	s.add(new Planet(20)); // Add a planet to the star's orbital system which orbits at a distance of 20 units.
	s.add(new Planet(66)); // Add another planet to the star's orbital system which orbits at a distance of 66 units.

	while (true) {
		s.tick();
	}
}

Can refer the below link for details:
ehow.com/how_5579338_build-own-solar-system-java.html

- Steve October 02, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

class MilkyWay
{
//common methods
}

class SolarSystems extends MilkyWay
{

}
interface Planet
{
   void shape(;
   int noOfSatellites(;

    /* all method required for a planet
     */
}

Class Earth implements Planet extends SolarSystems
{
//implmentation
}

- Fargushan October 03, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

SOLR!!!!!!!!!!!!!!!!!!!

- maxiaophp September 10, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

declare a solar system interface with methods used by 9 planets. make 9 classes for planets and implement the solar system interface along with built in class members, methods and watever u like :)

- kisshor kumar March 30, 2014 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

declare a solar system interface with methods used by 9 planets. make 9 classes for planets and implement the solar system interface along with built in class members, methods and watever u like :)

- kisshor kumar March 30, 2014 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

declare a solar system interface with methods used by 9 planets. make 9 classes for planets and implement the solar system interface along with built in class members, methods and watever u like :)

- kisshor kumar March 30, 2014 | Flag Reply
Comment hidden because of low score. Click to expand.
-1
of 1 vote

Design Solar System LOL

- Loler October 02, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

Will the real Loler please stand up?

- Anonymous October 02, 2012 | Flag
Comment hidden because of low score. Click to expand.
1
of 1 vote

I am still LOLing

- Loler October 02, 2012 | Flag
Comment hidden because of low score. Click to expand.
1
of 1 vote

Keep LoLing

- Anonymous October 02, 2012 | Flag
Comment hidden because of low score. Click to expand.
-1
of 1 vote

Take solar panels that generate electricity enough for the requirement.
Place them such that they are at perpendicular to east-west line. In case of large number of panels they could be placed in a circle with a tower in the center which reflects light on the panels. this ensures that no matter which direction the sunlight comes from we get energy.
Connect rest of the circuit to a battery or the device. Add switches, transformers, cables and wah la!!

- Noobie October 02, 2012 | Flag Reply


Add a Comment
Name:

Writing Code? Surround your code with {{{ and }}} to preserve whitespace.

Books

is a comprehensive book on getting a job at a top tech company, while focuses on dev interviews and does this for PMs.

Learn More

Videos

CareerCup's interview videos give you a real-life look at technical interviews. In these unscripted videos, watch how other candidates handle tough questions and how the interviewer thinks about their performance.

Learn More

Resume Review

Most engineers make critical mistakes on their resumes -- we can fix your resume with our custom resume review service. And, we use fellow engineers as our resume reviewers, so you can be sure that we "get" what you're saying.

Learn More

Mock Interviews

Our Mock Interviews will be conducted "in character" just like a real interview, and can focus on whatever topics you want. All our interviewers have worked for Microsoft, Google or Amazon, you know you'll get a true-to-life experience.

Learn More