Sie sind auf Seite 1von 4

Data Structures:

1) Sort and display a list of 10 numbers in ascending order. Use either selection sort or bubble sort
for this.

2) Write a program that will help Air Traffic Control for an airport to view the sequence of flights
ready for take-off. The airport can accommodate 10 flights waiting for take-off at any point in time.
Each flight has a unique 3 digit numeric identifier.

Each time a flight takes-off, Air Traffic Control adds a flight to the waitlist. Each time a flight is
added to the waitlist, the list of flights waiting to take-off must be displayed.
When a flight is cleared for take-off, Air Traffic Control removes the flight from the waitlist.
Each time a flight takes-off, the list of flights waiting to take-off must be displayed.
Sequence of take-off is the sequence of addition to the waitlist.

Java
Introduction and Basics
1. Why the code below does not compile?
public class A{
public static void main(String str[]){
String d = "\u000d";
System.out.println(d);
}}
2. The code above has been modified. Now will it compile?
public class A{
public static void main(String str[]){
// String d = "\u000d";
String d = "\u0032";
System.out.println(d);
}}
3. Why does this code print 0?
public class A{
public static void main(String str[]){
byte b= (byte) 256;
System.out.println(b);
}}
4. Why line 2 works and line 3 gives compilation error?
public class A{
public static void main(String str[]){
byte b=1;
b++; //line 2
b=b+1; //line 3
}}

5.

Why does the code throw an exception at runtime?


public class A{
public static void main(String str[]){
byte b=1;
b=(byte)(b/0);
}}
Will it throw an exception if 0 is replaced by 0.0?

Classes and Methods, Package


1. Why can the 2 methods below be overloaded?
static void f(int[] i){}
static void f(int... x){}
2. If the first and the second count() call prints 3 and 2 , what will the last count() call print?
class A{
static void count(String... objs){
System.out.println(objs.length);
}
public static void main(String[] args) {
count(null,null,null);
count(null,null);
count(null);
}}
3. Why does the code end up in compilation error?
class A{
static void count(float f){
System.out.println(objs.length);
}
public static void main(String[] args) {
count(1.2);
}}
4. If there is a public class then the file must be named after the public class name. Why?
5. Given the following three source files:
package my;
public class Horse { }
package my.ex;
public class Parrot { }
package my.ex.one;
public class Dog { int foo = 5; }

And the following incomplete source file:


// insert code here
public class MyClass {
Horse r;
Parrot p;
Dog d;
void go() {
int x = d.foo;
}}
Which statement(s) must be added for MyClass to compile? (Choose all that apply.)
A.
B.
C.
D.
E.
F.
G.
H.

package my;
import my.*;
package my.*;
package my.ex;
import my.ex.*;
import my.ex.one;
package my.ex.one;
package my.ex.one.Dog;

Did you know?


1) Yahoo is the acronym for "Yet Another Hierarchical Officious Oracle . Yahoo! founders Jerry
Yang and David Filo selected the name because they considered themselves yahoos, the
definition of which is: rude, unsophisticated, uncouth
2) Laughing lowers levels of stress hormones and strengthens the immune system. Six-year-olds
laugh an average of 300 times a day. Adults only laugh 15 to 100 times a day
3) The word "boot" or "booting" comes from the concept of bootstrapping, or pulling oneself up by
the bootstraps. Before PC's, computer operators would run a program called the bootstrap
loader. This loader did the initialization that is now automatic. The process became known as
bootstrapping and later booting.
4) Monday is the day of the week when the risk of heart attack is greatest. A ten year study in
Scotland found that 20% more people die of heart attacks on Mondays than any other day of the
week. Researchers theorize that its a combination of too much fun over the weekend with the
stress of going back to work that causes the risk increase
5) HP, Google, Microsoft, and Apple have one thing in common apart from the obvious that they
are IT companies. They were all started in garages.
6) Did you ever notice that the keyboard has its creator's last name on it- Mr. Qwerty !

7)

The ctrl, alt and delete combination that reboots the computer if it is held down long enough is
also known as the three finger salute in a computer. This sequence was coded by David Bradley
back in 1980 and it took him about five minutes !

Das könnte Ihnen auch gefallen