Advertisement
NB52053

JAVA_LAB_3

Oct 25th, 2016
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.04 KB | None | 0 0
  1. //Blue
  2.  
  3. package lab.pkg3;
  4.  
  5. public class Blue {
  6.    
  7.     public int x;
  8.     public static int y = 10;
  9.    
  10.      {x =500;}
  11.    
  12.    
  13.     {
  14.          System.out.println(x);
  15.     }
  16.    
  17.    
  18.     public Blue(int x) {
  19.    
  20.         this.x = x;
  21.     }
  22.    
  23.    
  24.       public static void main(String[] args) {   //  Main Function
  25.       Blue blue1 = new Blue(50);
  26.       System.out.println(blue1.x + " " + blue1.y);
  27.       blue1.y = 15;
  28.      
  29.      
  30.      
  31.      // System.out.println(Blue.y);
  32.        Blue blue2 = new Blue(100);
  33.       System.out.println(blue2.x + " " + blue2.y);
  34.     }
  35.    
  36. }
  37.  
  38.  
  39.  
  40. //SuperHero
  41.  
  42. package lab.pkg3;
  43.  
  44.  
  45.  
  46. public class SuperHero {
  47.    
  48.     public String name, power;
  49.    
  50.     public SuperHero(String name, String power){
  51.    
  52.         this.name = name;
  53.         this.power = power;
  54.    
  55.     }
  56.    
  57.     public void show(){
  58.         System.out.println(name+ " "+power);
  59.         //System.out.println(Blue.y);
  60.    
  61.     }
  62.    
  63.    
  64. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement