1.

  1. public class Test {
  2. public static void main(String[] args) {
  3. AAA aaa = new AAA();
  4. }
  5. }
  6. class AAA{
  7. BBB bbb = new BBB();
  8. }
  9. class BBB{
  10. AAA aaa= new AAA();
  11. }
  1. Exception in thread "main" java.lang.StackOverflowErro

2.

  1. public class Test {
  2. public static void main(String[] args) {
  3. AAA aaa = new AAA();
  4. }
  5. }
  6. class AAA{
  7. BBB bbb;
  8. }
  9. class BBB{
  10. AAA aaa;
  11. }

3

  1. public class Test {
  2. public static void main(String[] args) {
  3. AAA aaa = new AAA();
  4. }
  5. }
  6. class AAA{
  7. BBB bbb = new BBB();
  8. }
  9. class BBB{
  10. AAA aaa;
  11. }

4

  1. public class Test {
  2. public static void main(String[] args) {
  3. AAA aaa = new AAA();
  4. }
  5. }
  6. class AAA{
  7. static BBB bbb = new BBB();
  8. }
  9. class BBB{
  10. AAA aaa = new AAA();
  11. }