This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class Main { | |
| public static void main(String[] args) { | |
| int array[] = {1, 2, 3, 4, 5, 6, 9, 8 , 9, 3, 2, 12, 134, 3, 2, 134, }; // Инициализируем массив | |
| int maxNumber; // Объявляем переменную максимального числа | |
| int minNumber; // Объявляем переменную минимального числа | |
| maxNumber = minNumber = array[0]; | |
| for(int i : array) { // Создаем счетчик цикла в массиве | |
| if( i > maxNumber) { // Задаем логический оператор для сравнения массива и максимального числа в массиве |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 1. Чем отличается класс от объекта? | |
| класс определяет природу объекта, является абстрактным описанием, а объект - это конкретный экземпляр в классе | |
| 2. Как определяется класс? | |
| ключевым словом class и внутри класса указываются код и данные составляющие класс | |
| 3. Собственную копию чего содержит каждый объект? | |
| Каждый объект содержит собственную копию переменных экземпляра этого класса | |
| 4. Покажите, как объявить объект counter класса MyCounter, используя две отдельные инструкции. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package com.company; | |
| import java.lang.*; | |
| // ласс для вызова методов | |
| class HelpClass { | |
| // Возвращаемый метод текстовых блоков сообщений, | |
| // значения принимает типа int | |
| void helpon(int choise) { | |
| switch (choise) { | |
| case 1: | |
| System.out.println ("Инструкция if:\n"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import java.io.IOException; | |
| public class Main { | |
| // Программа для подсчета количества пробелов, | |
| // остановка при вводе точки | |
| public static void main(String[] args) throws IOException | |
| { | |
| char symbol; | |
| int space = 0; | |
| System.out.println ("Введите символ"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package com.company; | |
| // Программа для вывода квадратных корней чисел от 1 дл 99 | |
| // вместе с ошибкой округления | |
| public class Main { | |
| public static void main(String[] args) { | |
| // Инициализируем переменные | |
| double num, sroot, rerr; | |
| // Инициализируем цикл | |
| for (num = 1.0; num < 100.0; num++) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class Main { | |
| public static void main(String[] args) { | |
| int i, j; | |
| boolean isPrime; | |
| for (i = 2; i < 100; i++) { | |
| isPrime = true; | |
| for (j = 2; j <= i / j; j++) { | |
| if ((i % j) == 0) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class Main { | |
| public static void main(String[] args) { | |
| System.out.println("P\t Q\t AND\t OR\t XOR\t NOT"); | |
| p = true; q = true; | |
| System.out.print(p +"\t" + q + "\t"); | |
| System.out.print((p & q) + "\t" + (p | q) + "\t"); | |
| System.out.println((p ^ q) + "\t" + (!p)); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import java.util.Scanner; | |
| // Динамическая инициализация в операторе return | |
| public class Main { | |
| public static void main(String[] args) { | |
| Scanner sc = new Scanner(System.in); | |
| System.out.println("Введите Радиус: "); | |
| double radius = sc.nextDouble(); | |
| System.out.println("Введите Высоту: "); | |
| double height = sc.nextDouble(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import java.util.Scanner; | |
| public class Main { | |
| public static void main(String[] args) { | |
| Scanner sc = new Scanner(System.in); | |
| System.out.println("Введите Х: "); | |
| double x = sc.nextDouble(); | |
| System.out.println("Введите Y: "); | |
| double y = sc.nextDouble(); |
NewerOlder