...
 
Commits (2)
......@@ -11,7 +11,7 @@ class AttributeKill {
objectA = null;
A objectA = new A();
/* A objectA = new A();*/
/*should be null (not intiateated)*/
int a = objectA.atr;
......
/**
* Attribute or static
*/
class AttributeOrSystem {
public int System;
/* public int System; // error: int cannot be dereferenced*/
public static void main(String[] args) {
A objA = new objA();
A objA = new A();
objA.init();
......
/**
* Call without Parameter to Method
* error: variable a is already defined in method test(int)
*/
class BooleanSystemPrint {
......@@ -11,8 +15,8 @@ class BooleanSystemPrint {
public void test (int i) {
int a = i;
Boolean a = true;
System.out.println(a);
/* Boolean a = true;
System.out.println(a);*/
}
......
......@@ -3,12 +3,14 @@
*/
class CompareClassAttributes {
public A objectA;
public B objectB;
public static void main(String[] args) {
A objectA = new A();
B objectB = new B();
objectA.init();
objectB.init();
......@@ -19,9 +21,6 @@ class CompareClassAttributes {
result = objectA.atr + objectB.atr;
}
......
/**
* Check if local variable can be initializsed with class
*/
class LocalInitClass {
public static void main(String[] args) {
LocalInitClass test = LocalInitClass();
test.algorithm();
Test test = new Test();
/*giving the localVariable itself as parameter*/
test.algorithm(test);
}
}
class Test{
public int algorithm() {
public Test testlocalVar;
TestlocalVar = Test;
public int algorithm(Test Test) {
}
}
/*maybe as inner class?*/
class Test{
testlocalVar = Test;
return 0;
}
}
\ No newline at end of file
}
\ No newline at end of file
......@@ -11,16 +11,14 @@ class LocalVariableOverwriteAttribute {
int localVar = varInt;
System.out.println(localVar);
}
public static void main(String[] args) {
LocalVariableOverwriteAttribute test = LocalVariableOverwriteAttribute();
LocalVariableOverwriteAttribute test = new LocalVariableOverwriteAttribute();
test.algorithm();
}
}
\ No newline at end of file
class NoConstructedObjectCall {
public static void main(String[] args) {}
public void test() {
A objA = new objA();
int b = objA.atr;
return;
......@@ -17,6 +15,7 @@ class NoConstructedObjectCall {
}
class A {
public int atr;
public void init () {
......
class OverwriteWithnonedecalredVariable {
class OverwriteAttributeWithUndeclaredVariable {
public static void main(String[] args) {}
public String a;
public void test () {
/*should break here because of undeclared unknown variable*/
int a = i;
......@@ -14,9 +12,6 @@ class OverwriteWithnonedecalredVariable {
}
class String {
}
class String {}
/**
* Tests a lot of double naming
*/
class RightVariable {
public static void main(String[] args) {}
public int Test;
public Test Test(Test Test) {
return Test;
}
public void testMethod() {
/*init Test object*/
Test test = new Test();
/*call and init attribute of class*/
test.Test = 3;
/*init RightVariable Attribute*/
Test = 5;
/*Overwrite test attribute with RightVariable class Attribute*/
test.Test = Test;
/*call local method with test*/
Test(test);
/*Overwrite class Test with with local method Test, with itself given as an obj ref..*/
test = Test(test);
}
}
class Test {
public int Test;
public void Test() {}
}
\ No newline at end of file
/**
* Should find out if right variable (local in method) is taken
*/
class RightVariable {
public Test Test;
public Test Test(Test Test) {
return Test;
}
public static void main(String[] args) {
RightVariable test = RightVariable();
test.Test();
test.Test;
Test test = new Test();
}
}
class Test {
}
\ No newline at end of file
/**
* Declare void as type for variale
* java:6: error: '(' expected -> for method
*/
class VoidAttribute {
public void a;
public static void main(String[] args) {}
}
class WrongReturnTypeVoid {
public static void main(String[] args) {}
public void a() {
/*should not allow return of integer*/
......