Chapter 1 Flashcards
what is an object oriented programming language
This is a language where code is defined in classes and those are instantiated into objects when called upon in runtime.
what is the release interfall of new Java versions.
Every 6 months.
List 5 benefits of Java
Object oriented, Encapsulation, Platform independent, Robust, Simple, Secure, Multithreaded, Backward Compatibility,
What is a java class
A class is a repeatable buildingblock that can be used to build up your programs. A class contains all parts and characteristics of such a building block
What is the difference between a object and a class
A object is a copy of a class used in runtime.
The (JVM) runtime enviroment uses a class to create a memory object.
What are the two primary elements of a Java Class
Methods
Fields (also known as Variables)
what does the {public} keyword do?
This is a “acces modifier” that declares the level of exposure to other parts of the java program. Public means any part of the program can use this method or class.
what is the minimal syntax required to create a java class.
public/private class Car { } First the acces modifier keywords Second the class keyword Third is the name of the class And the curly brackets contain the methods and variables
What does the private keyword do?
This is a “acces modifier” that declares the level of exposure to other parts of the java program. Private means that this class or method can NOT be used by other parts of the java program.
What is this : //
The begin of a comment in the code. A single line of text that is ignored during runtime.
What is the correct syntax for a Multiline comment
/* (beginning)
- (lines, repeat until you have enough )
- / (end of comment)
What is the difference between a multiline comment and Javadoc comment
it starts with /** instead of /* and it is read by the javadoc tool where other comments are ignored.
What is the JDK
Java Developers Kit, everything you need to create and run a Java program.
What is the JRE
The Java runtime enviroment is part of the JDK and is the subset of java tools that run a program.
what is the correct filename for a Javafile that contains
public class zoo
zoo.java a java file can only contain one public class and the name of the javefile has to match the name of this class.
What is the main method
The main method tells the java enviroment where to begin working.
Describe the static keyword
The static keyword binds a method to its class name. When other parts of the program call the class the static method is the entry point of this class.
describe the void keyword
the void keyword is a return type for a method. This type declares that the method won’t return anything and returns control silently.
When to use the void keyword
use this return type keyword if your method or class does not give a response.
what is contained in a method signature between these symbols ()
This is the parameter list, A list of variables with the correct types and names. For example
(int month) a integer named month
(string brand) a string named brand
(string[] args) a array of strings or ‘arguments’
What is the correct java command to run the Zoo.class inside the city package without args
java city.Zoo
How do you pass a argument into a object if your value contains a space like - The Netherlands
Use quotes, : “The Netherlands” is a single string value for java arguments.
How to run a class without compiling it ?
Use the full file name of the class. For example Zoo.java instead of just Zoo.
In what situation can you run code without compiling it ?
This is only possible for a program that is “Single file source code”.
What are the valid options to run a program using the java command while passing the classpath to the jre
- cp : java -cp Filestructure ClassName
- classpath : java -classpath Filestructure ClassName
- -class-path : java –class-path Filestructure ClassName
What are the valid options to compile a program using the javac command while passing the classpath to the jdk
- cp : javac -cp Filestructure ClassName
- classpath : javac -classpath Filestructure ClassName
- -class-path : javac –class-path Filestructure ClassName
what do the -c and –create options do when using the jar command
Creates a new JAR file
what do the -v and –verbose options do when using the jar command
Prints details when working with JAR files
what do the -f and –file options do when using the jar command
it passes the filename of the new JAR file to the jar command.
what does the -C options do when using the jar command
It points to a directory that contains files to be used to create the JAR
What is the correct order of the following elements of a java file. A : Import statements B : Field declarations C : Package declaration D : Method Declarionts E : Class Declarations
1 = C : Package Declaration 2 = A : Import statements 3 = E : Class Declarations 4 = B : Field declrations 5 = D : Method Declarations
for java 11 what is the minimum and maximum amount of public classes in a .java file?
Minimum = 0 Maximum = 1
Does java allow operator overloading
No
Java code compiled on windows can run on linux
Yes
Java has pointers to specific locations in memory
No, java points to objects.