Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 3

National Aviation University

Faculty of Cybersecurity, Computer and Software Engineering


Software engineering department

Software development studio

Module control work

VARIANT № 15

Prepared by:
student of SE-227 en.,
Frynas Vadym

Accepted by:
Tkachenko O.A.
1.A static class i.e. created inside a class is called static nested class in java. It cannot
access non-static data members and methods. It can be accessed by outer class name.

o It can access static data members of outer class including private.

o Static nested class cannot access non-static (instance) data member or method.

class Human{
static String name;
static class Teacher{
String Discipline;
void print(){System.out.println("Name: "+name+", Discipline:
"+Discipline);}
}
public static void main(String args[]){
Human.Teacher obj=new Human.Teacher();
obj.print();
}
}

2. Inheritance is the process wherein characteristics are inherited from ancestors.


Inheritance in java can be defined as a mechanism where a new class is derived
from an existing class. It is possible for classes to inherit or acquire the properties
and methods of other classes, just like a son can acquire some traits and behavior
from his father. In Java inheritance is declared using the extends keyword. You
declare that one class extends another class by using the extends keyword in the
class definition.
class Human {
String name;
}
class Teacher extends Human{
String Discipline;
void print(){System.out.println("Name: "+name+", Discipline: "+Discipline);
}
}
public class Main {
public static void main(String[] args) throws CustomException {
Teacher teacher=new Teacher();
teacher.print();
}
Practice
package com.company;

import java.util.Scanner;

public class Main {

public static void main(String[] args) {


Scanner sc = new Scanner(System.in);
System.out.println("Write a new number");
String number=sc.nextLine();
char[] digits=number.toCharArray();
int FirstDigit= Character.getNumericValue(digits[0]);
if(FirstDigit==7)
{
FirstDigit=0;

}else if(FirstDigit==8)
{
FirstDigit=1;
}else if(FirstDigit==9)
{
FirstDigit=2;
}
else
{
FirstDigit+=3;
}
String NewNumber=number.replace(digits[1],(char)(FirstDigit+'0'));
System.out.println(NewNumber);
}
}

You might also like