GoConqr has a new look! Let us know what you think.

Flashcards

Week 1 Recap Questions

Artemis Mills Computer Studies none English 51 cards

What are objects / instances of a class?

Cards in this deck (51)

  1. 1What is Java?Java is a high-level (easily human readable), compiled (transformed so computers can run it), strongly-typed (static typed), object oriented programming language
  2. 2What are the benefits of Java?1.Platform independent (write once, run anywhere - WORA)
    2.C-language inspired syntax
    3.Automatic memory management (grabage collector)
    4.Extensive built-in runtime library (Java Runtime Environment (JRE)
    5.Rich open-source community
  3. 3What is the difference between the JDK, JRE, and JVM?JDK (Java Development Kit): Contains a compiler and debugger + JRE
    JRE (Java Runtime Environment): Contains the runtime libraries that our code may be using + JVM.
    JVM (Java Virtual Machine): Enables a computer to actually execute a Java program. The JVM is what
    actually runs the bytecode (compiled) and then translate it so that the machine can understand the bytecode
  4. 4If we want to both write and run Java programs we install a ________.JDK
    we should install a JDK (because it has a compiler). If we only want to run Java programs, we should install a JRE
  5. 5In order to run a Java program, what needs to happen first?Write the Java code and COMPILE
  6. 6What is the significance of the main method?Without a main method your application will have no entry point. Yes, it is required for any executable program. If you try to execute a Java class, the JVM will look for a main method to invoke it.
    The main method in Java is public so that it's visible to every other class, even which are not part of its package. if it's not public JVM classes might not able to access it. ... The main method is static in Java so that it can be called without creating any instance
  7. 7What is an IDE?Integrated Development Environment:
    Enables programmers to consolidate the different aspects of writing a computer program.
    In other words, It combines common activities of writing software into a single application: editing source code, building executables, and debugging.
    Examples: Springtool Suite, Eclipse, RStudio
  8. 8What naming conventions does Java utilize?Classes: Class names should be NOUNS with the first letter of each word capitalized. (ex. public class SodaCan)
    Methods: VERBS, mixed case with the first letter lowercase, and every
    subsequent word's first letter capitalized (ex. public static void makeALotOfNoise() {})
    Variables: NOUNS, but same naming convention as methods (ex. int numberOfLegs = 10;)
    Project names: snake case (all lower case with hyphens between words) (ex. my-first-project)
  9. 9How can I write a Java application without an IDE such as Spring Tool Suite?Use a text editor
  10. 10What is Bash?Bourne-Again SHell:
    Bash is a command line interpreter that typically runs in a text window where user can interpret commands to carry out various actions.
    The combination of these commands as a series within a file is known as a Shell Script.
    Bash can read and execute the commands from a Shell Script.
  11. 11What are classes in Java?Classes are the blueprint to create objects.
    Using the class keyword declares a class.
    ie: public class Student {}
  12. 12What do classes contain?A Java class can contain the following building blocks:
    1. Fields (variables within Java class)
    2. Constructors (A constructor in Java is a block of code similar to a method that's called when an instance of an object is created. Here are the key differences between a constructor and a method: A constructor doesn't have a returntype).
    3.Methods (A method is a group of Java statements that perform some operation on some data, and may or may not return a result)
    4. Nested Classes (class defined within another class (encapsulation))
  13. 13What are objects / instances of a class?A Java object is a member (also called an instance) of a Java class. Each object has an identity, a behavior and a state.
    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.
    An object is created using the keyword "new".
    What are objects / instances of a class?
  14. 14What is the purpose of packages in Java?Packages are a way of organizing classes, interfaces, and enums in a hierarchical manner.
    Packages follow a naming convention of lowercase characters separated by periods
    ie: com.revature.app
  15. 15What is special about the java.lang package included in the Java runtime libraries?Provides classes that are fundamental to the design of the Java programming language.
    Following are the Important Classes in Java.lang package :
    Boolean, Byte, Character.Subset, Complier (just to name a few)
  16. 16What are the primitive types in Java?primitive variables: directly store values "within them" in memory
    Types:
    1. boolean
    2. integral types (byte, short, char, int, long)
    *char is a special one that is intended to store characters
    3. floating-point types (float and double)
  17. 17Is String a primitive type?String is non-primitive because only classes can have methods. Primitives can not. And String needs many functions to be called upon while processing like substring, indexof, equals, touppercase. It would not have been possible without making it class
  18. 18What are reference types?reference variables: refer to other locations in memory. In particular, reference variables "point" to the location of objects in memory
    A reference type is a data type that’s based on a class rather than on one of the primitive types that are built in to the Java language
    Examples: Annotation, Array, Class, Enum, Interface
  19. 19How are primitives and references different from each other?Reference variables are not pointers but a handle to the object which is created in heap memory.
    The main difference between primitive and reference type is that primitive type always has a value, it can never be null but reference type can be null, which denotes the absence of value.
    So if you create a primitive variable of type int and forget to initialize it then it's value would be 0, the default value of integral type in Java, but a reference variable by default has a null value, which means no reference is assigned to it.
  20. 20What does it mean when a reference type has a value of null?null value simply means that the variable does not refer to an object in memory.What does it mean when a reference type has a value of null?
  21. 21What makes an object eligible for garbage collection?An object is marked as eligible to be garbage collected when it can no longer be accessed, which can happen when the object goes out of scope.
    It can also happen when an object's reference variable is assigned an explicit null value or is reinitialized.
  22. 22What is garbage collection?Automatic Memory Management
    The garbage collector attempts to reclaim memory which was allocated by the program, but is no longer referenced—also called garbage.
  23. 23What is a constructor and its purpose?subroutines that are similar to methods, except that they are invoked in order to actually create the object.
    A constructor is declared like a method, except its method signature does not contain a return type, and a constructor always has the same name as the class. The new object returned from the constructor is always of the class in which the constructor is declared.
    What is a constructor and its purpose?
  24. 24Provide an example of formating a constructor.Provide an example of formating a constructor.
  25. 25What is constructor overloading?The concept of having more than one constructor with different parameters so that every constructor can perform a different task.What is constructor overloading?
  26. 26What is constructor chaining?Constructor chaining occurs through inheritance. A sub class constructor’s task is to call super class’s constructor first. This ensures that creation of sub class’s object starts with the initialization of the data members of the super class. There could be any numbers of classes in inheritance chain. Every constructor calls up the chain till class at the top is reached.
    Constructor chaining can be done in two ways:
    1. Within same class: It can be done using this() keyword for constructors in same class
    2. From base class: by using super() keyword to call constructor from the base class.
  27. 27What are the two uses of the this keyword? In terms of memory management, what is the stack and heap?This keyword in Java is a reference variable that refers to the current object of a method or a constructor.
    1. Using ‘this’ keyword to refer current class instance variables
    2. Using this() to invoke current class constructor
  28. 28What are methods?A method is a group of Java statements that perform some operation on some data, and may or may not return a result.What are methods?
  29. 29What are arguments v. parameters?An argument is a VALUE passed to a function when the function is called.
    A parameter is a VARIABLE used to define a particular value during a function definition.
    What are arguments v. parameters?
  30. 30What does method return type mean?A method can accept data from outside and can also return the results. To return the result, a return statement is used inside a method to come out of it to the calling method.
    In Java, return is a keyword that is used to exit from the method only with or without returning a value. Every method is declared with a return type in java and it is mandatory for Java methods.
    Return type may be a primitive data type like int, float, double, a reference type, or void type which represents “return nothing”. i.e, they don’t give anything back.
  31. 31What is the purpose of the static keyword?In Java, static keyword is mainly used for memory management. It can be used with variables, methods, blocks and nested classes.
    It is a keyword which is used to share the same variable or method of a given class.
    Basically, static is used for a constant variable or a method that is same for every instance of a class. The main method of a class is generally labeled static.
  32. 32What can we use the static keyword with in Java?It can be used with variables, methods, blocks and nested classes.
  33. 33How can I access a static variable?Static variables can be accessed by calling with the class name ClassName.VariableName
  34. 34How do I invoke a static method?We can invoke a static method by using its class reference.How do I invoke a static method?
  35. 35What are instance variables?Instance variables in Java are non-static variables which are defined in a class outside any method, constructor or a block
  36. 36Can a static method access an instance variable directly?We cannot access non-static variables or instance variables inside a static method. Because a static method can be called even when no objects of the class have been instantiated.
  37. 37What are the variable scopes in Java?Scope of a variable is the part of the program where the variable is accessible
    1. Class scope (sometimes known as global scope): any field that has the static keyword is class scoped. This means the variable belongs to the class itself.
    2. Instance scope: any field that is non-static (does not have the static keyword) is instance scoped. This means that every single instance has its own copy of this variable
    3. Method scope: any variable that is declared inside of a method is method scoped. This means that you can only access this variable within that particular method, and the variable
    is destroyed whenever the method is done executing. (this method exists within the stack frame)
    4. Block scope: within methods, we can have different code blocks (if statement blocks, for loops, while loops, etc.) Variables that are declared inside of those blocks are only available
    within those blocks
  38. 38Can an instance method access an instance variable directly?Yes! Instance methods can access instance variables and instance methods directly.
  39. 39What is Git?Git is the most commonly used version control system. Git tracks the changes you make to files, so you have a record of what has been done, and you can revert to specific versions should you ever need to. Git also makes collaboration easier, allowing changes by multiple people to all be merged into one source
  40. 40What is a local git repository?Git local repository is the one on which we will make local changes, typically this local repository is on our computer. Git remote repository is the one of the server
  41. 41What is a remote git repository?A Git repository that hosted on the Internet or another network
  42. 42What is the difference between Git and Github?Simply put, Git is a version control system that lets you manage and keep track of your source code history. GitHub is a cloud-based hosting service that lets you manage Git repositories. If you have open-source projects that use Git, then GitHub is designed to help you better manage them.
  43. 43What are some of the other popular repository hosting websites besides Github?GitLab.
    BitBucket.
    SourceForge. ...
    Launchpad. ...
    Google Cloud Source Repositories. ...
    AWS CodeCommit. ...
    Phabricator. ...
    Gogs (Self-Hosted)
  44. 44What is the purpose of configuring the SSH keys for Github and Git Bash?When working with a GitHub repository, you'll often need to identify yourself to GitHub using your username and password. An SSH key is an alternate way to identify yourself that doesn't require you to enter you username and password every time.
  45. 45Whenever we make changes to files or add/remove files from our local repository, what commands are needed to actually upload these changes to the remote repository?git commit : used to save your changes to the local repository
    git push: is used to upload local repository content to a remote repository. Pushing is how you transfer commits from your local repository to a remote repo
    git add: This step allows you to choose what you are going to commit.
    git remote add origin https://github.com/yourusername/your-repo-name.git
  46. 46What arithmetic operators are there? What are the assignment operators? What are the comparison operators? What are the logical operators?+: Addition
    -: Subtraction
    *: Multiplication
    %: Modulus (get the remainder when dividing, ex. 5 % 2 = 1)
  47. 47What is numeric promotion?Numeric promotion is the conversion of a smaller numeric type to a larger numeric type, so that integer and floating-point operations may take place. In numerical promotion, byte, char, and short values are converted to int values.
  48. 48Numeric Promotion Rules1.If two values have different data types, Java will automatically promote one of the values to the larger of the two data types.
    2. If one of the values is integral and the other is floating-point, Java will automatically promote the integral value to the floating-point value’s data type.
    3.Smaller data types, namely byte, short, and char, are first promoted to int any time they’re used with a Java binary arithmetic operator, even if neither of the operands is int.
    4. After all promotion has occurred and the operands have the same data type, the resulting value will have the same data type as its promoted operands (A value involved in an operation is called an operand)
  49. 49What are the assignment operators?Assignment Operators
    =
    +=
    -=
    *=
    /=
    %=
  50. 50What are the comparison operators?Comparison Operators
    *
    How we compare values
    ==: equals
    !=: not equal
    >: greater than
    <: less than
    >=: greater than or equal to
    <= : less than or equal to
  51. 51What are the logical operators?

Information

Description
none Computer Studies Flashcards on Week 1 Recap Questions, created by Artemis Mills on 21/10/2021.
Created by
Artemis Mills
Views
47
Rating

Feedback

What is it about?

What do you think of the new look?

How do you like it?