1. Compiler - takes the entire programming code written in high language and translates the whole of it into machine code at once. After this process the an executable file will be ready to run. The translation takes some times to be done, but after that execution is so fast. 2. Interpreter - takes each single instructions of the code translates it and then executes it on its own. The translation step is before the program runs is fast, but execution is slow. JDK = JRE + development tools JRE = JVM + library class JDK -> Java Development Kit. A kit which provides the environment to develop and execute (run) Java program. JRE -> Java Runtime Environment. Provides environment to only run. JVM -> Java Virtual Machine f * Compiled: Fortran, C, C++, Pascal, Haskell, Rust, Go * Interpreted: JavaScript, PHP, Python, Ruby Java both compiled and interpreted language. Terminalda : javac Main.java yazdiqda, source fayli(.java) bytecode(.class) faylina cevirir. Terminalda: java Main (bu z...
Class definition: -> A class — in the context of Java — is a template used to create objects and to define object data types and methods. A class in Java is a logical template to create objects that share common properties and methods. Object definition: -> A Java object is a member (also called an instance ) of a Java class. Each object has an identity, a behavior(methods) and a state(fields). The state of an object is stored in fields (variables), while methods (functions) display the object's behavior. Objects are created at runtime from templates, which are also known as classes . Variables: 1. Object variables (instance or state or field): Funksional olaraq obyektin ozelliklerini ifade edir. Object variables hem primitive ham de reference deyishenler ola biler. Local variable-lardan ferqli olaraq, Object variable - larin default deyerleri movcuddur. Mes: package org.example ; public class Car { public String make ; ...
1. if(), if() else(), if() else if() else() a) Simple if else case Scanner in = new Scanner( System . in ) ; int a = in .nextInt() ; if ( a > 0 ) { System . out .println( "Positive" ) ; } else if ( a == 0 ) { System . out .println( "Neutral" ) ; } else { System . out .println( "Negative" ) ; } System . out .println( "Continue..." ) ; b) Wrong if else case Scanner in = new Scanner( System . in ) ; int grade = in .nextInt() ; if ( grade > 90 && grade <= 100 ) { System . out .println( "A" ) ; } else if ( grade > 80 ) { System . out .println( "B" ) ; } else { System . out .println( "Fail" ) ; } System . out .println( "Continue..." ) ; When we input for example 150 code crashes. Random random = new Random() ; int grade = random.nextInt( 100 ) ; if (grade > 90 ) { System. out .println(grade + " A" ) ; } else if (grade > 80 ) { System. out .printl...
Комментарии
Отправить комментарий