Documente online.
Zona de administrare documente. Fisierele tale
Am uitat parola x Creaza cont nou
 HomeExploreaza
upload
Upload




Introduction to objects, Everything is an Object, Controlling program flow.

computers


Introduction to objects, Everything is an Object, Controlling program flow.

Questions

  1. What is an Object? What is a class?
  2. Which from the following are access specifiers:
    1. private
    2. local
    3. default
    4. protected
    5. public
  3. There are some differences between Interface and Abstract Class? If yes, enumerate some of them.
  4. Which are the parts of a method?
  5. What is wrong in the following code?

class Shape



public double getArea()

}

  1. What javadoc tag is used to describe the method parameters?
  2. Based on operator precedence order the following operator types:

Arithmetic (and shift)

Relational

Conditional (ternary)

Unary

Assignment

  1. What will be the results of the following code?

.

int s = 0;

for (int i = 0; i < 10; ++i)

System.out.println "Result: " + s);

Problems

  1. Create a switch statement that prints a message for each case, and put the switch inside a for loop that tries each case. Put a break after each case and test it, then remove the breaks and see what happens.
  2. Write a program to transform a decimal number in a binary one.
  3. Write a program to compute all prime numbers less than a given number.

Initialization & cleanup

Questions:

  1. What is the role of the constructor?
  2. What is the meaning of the default constructor?
  3. Does the java syntax support constructor overloading?
  4. How can you distinguish the overloaded methods?
  5. Find and explain the errors from the following code.

class Person

public Person(String firstName, String lastName)

public Person(String firstName, String lastName, int age)

public void print()

.

}

  1. When are initialized the static members of a class?
  2. What will be the result of the execution for the following code:

public class TestOverloading

private void print(double d)

private void print(int i)

private void print(char c)

public static void main(String[] args)

}

  1. When and why should we use finalize() method?

Problems

  1. Create a class with two (overloaded) constructors and call the second constructor inside the first one.
  2. Create a class with a static String field that is initialized at the point of definition, and another one that is initialized by the static block. Add a static method that prints both fields.

Test:

  1. Which is the order of initialization of members within a Java class?
  2. Create a class that creates a two dimensional array of integers named lincol. Initialize each array element with the sum of its indices. For example, lincoln should be initialized to , or . Print out all the values stored in the lincoln array.

Document Info


Accesari: 1293
Apreciat: hand-up

Comenteaza documentul:

Nu esti inregistrat
Trebuie sa fii utilizator inregistrat pentru a putea comenta


Creaza cont nou

A fost util?

Daca documentul a fost util si crezi ca merita
sa adaugi un link catre el la tine in site


in pagina web a site-ului tau.




eCoduri.com - coduri postale, contabile, CAEN sau bancare

Politica de confidentialitate | Termenii si conditii de utilizare




Copyright © Contact (SCRIGROUP Int. 2024 )