Procedimientos de java

Páginas: 3 (597 palabras) Publicado: 9 de abril de 2010
**
Question 1)
What will happen when you attempt to compile and run this code?
public class MyMain
{
  public static void main(String argv)
  {
    System.out.println("Hello cruel world");
 }
}
1) The compiler will complain that main is a reserved word and cannot be used for a class
2) The code will compile and when run will print out "Hello cruel world"
3) The code will compile butwill complain at run time that no constructor is defined
4) The code will compile but will complain at run time that main is not correctly defined
**Question 2)
Which of the following are Javamodifiers?
1) public 2) private 3) friendly 4) transient 5) vagrant
**Question 3)
What will happen when you attempt to compile and run this code?
class Base
{
  abstract public void myfunc();
 public void another()
  {
    System.out.println("Another method");
  }
}

public class Abs extends Base
{
  public static void main(String argv[])
  {
    Abs a = new Abs();
    a.amethod();  }

  public void myfunc()
  {
    System.out.println("My func");
  }

  public void amethod()
  {
    myfunc();
  }
}
1) The code will compile and run, printing out the words "My Func"2) The compiler will complain that the Base class is not declared as abstract.
3) The code will compile but complain at run time that the Base class has non abstract methods
4) The compiler willcomplain that the method myfunc in the base class has no body, nobody at all to looove it
**Question 4)
What will happen when you attempt to compile and run this code?
class Base
{
  public finalvoid amethod()
  {
    System.out.println("amethod");
  }
}

public class Fin extends Base
{
  public static void main(String argv[])
  {
    Base b = new Base();
    b.amethod();
  }
}1) Compile time error indicating that a class with any final methods must be declared final itself
2) Compile time error indicating that you cannot inherit from a class with final methods
3) Run...
Leer documento completo

Regístrate para leer el documento completo.

Estos documentos también te pueden resultar útiles

  • Funciones y procedimientos en java
  • Oracle y Los Procedimientos Almacenados Desarrollados En Java
  • Java Basico
  • Java
  • Java
  • Java
  • java
  • JAVA

Conviértase en miembro formal de Buenas Tareas

INSCRÍBETE - ES GRATIS