Day 1 Flashcards

1
Q

What’s an assembly language?

A
  • A language created to make programming easier.
  • Keywords like add, sub, result.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

How can you execute an assembly code?

A

Using an assembler

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Which languages are machine dependent?

A

Machine language
Assembly language
However, high-level languages are machine independent

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What’s a source code?

A

It’s a program written using a high-level programming language

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

How is an interpreter different from a compiler?

A

An interpreter translates and executes the code line by line every time you run the program, so it gives an immediate feedback on errors

On the other hand, a compiler doesn’t do that, it translates the whole code all at once into a machine code executable file, so reporting of any error will be after the compilation

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What’s the term for a predefined Java code that can be used to develop programs?

A

API
Application Programming Interface

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What’s the term for a predefined Java code that can be used to develop programs?

A

API
Application Programming Interface

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Enumerate Java editions

A

• Java Standard Edition (SE)
• Java Enterprise Edition (EE)
• Java Micro Edition (ME)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Enumerate Java editions

A

• Java Standard Edition (SE)
• Java Enterprise Edition (EE)
• Java Micro Edition (ME)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What are these environments:
Eclipse, IntelliJ IDEA & NetBean?

A

They’re examples of Integrated Development Environment (IDE)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What’s JDE?

A

JDE (** Java Development Environment**)
= Java Development Kit (JDK) + Java Virtual Machine (JVM)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Which one doesn’t contain a code editor: JDE or IDE?

A

JDE
It includes all the essential tools to compile and run Java programs, but doesn’t include a code editor for writing and editing code

However an IDE contains a code editor and all the essential Java tools in addition to debugging tools

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Which environment gives Java the advantage to be machine independent?

A

Java Virtual Machine
which executes Java bytecode in the machine according to its requirements

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What’s the difference between these two lines?
1. return String method draw() {
code block
}
2. draw (“tree”);

A
  1. It’s method declaration
  2. This is method calling
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

True of false?
We can NOT have a Java program without a main method

A

True

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Which convention is used to name a class?

A

Pascal Case Convention

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

Write a complex variable name its correct convention

A
  • The right convention is Camel Case
  • Example: drawAPlane/ bendTheKnee
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

public class Main {
code block
}

This program won’t work, give the reason

A

Because there’s no main method, so the correct code must be like this:
public class main {

   public static void                                                                  
   main(String[] args)  {
  
   }

}

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

What’s the out in System.out.print() method?

A

out is an object (field) of a class (which is System)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
20
Q

What’s the difference betweenprintln & print methods?

A

println displays parameters with lines breaking between them on the console window

print displays parameters all in one line one after another

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
21
Q

True or false?
The naming of a java file mustn’t necessarily be the same name of the class

A

False
It’s a must that the saved java file is named after the name of the class

22
Q

Using cmd to compile a java source code stored in desktop, what to type in cmd to guide it to desktop?

A

cd Desktop

23
Q

Using cmd to compile a java source code stored in desktop, what to type in cmd to guide it to desktop?

A

cd Desktop

24
Q

One of the following files extensions is the right one for JVM to run:
File.java
File.class

A

File.class
It’s the compiled file (bytecode) that can be used by JVM to be executed in any type of machine

25
Q

One of the following files extensions is the right one for JVM to run:
File.java
File.class

A

File.class
It’s the compiled file (bytecode) that can be used by JVM to be executed in any type of machine

26
Q

What does this line in cmd mean?
C:\Users\Adel\Documents>javac Results.java

A

We order java compiler (javac) to compile a java file called Results which exists in Documents

Note how the file java names always start with a capital letter; it’s because it must take the naming of the file class and the naming of classes follow Pascal Case Convention

27
Q

In a standard newly-made java program, there’s an option to run the program starting from ‘Main.main()’. What does this quotated sentence mean?

A

It means that the class Main has a method called main which was accessed using the dot operator.
So running the program will execute what the method main entails

28
Q

Mention another use for the comments function besides writing notes?
Note: we mean by comments function the use of ‘//’ and ‘/* */’

A

Comments can also be used to eliminate a code so that the compiler ignores it (or part of it) when this code is suspected to cause an error. So if after the elimination the program runs smoothly that means the suspected code was incorrect

29
Q

What to use in order to make the compiler ignore a multi-line text?

A

We use a comment specifically this one:
/* the comment that
we wish to be ignored
by the compiler */

30
Q

How to write the main method quickly in a new class?

A

Write **psvm*
public static void main

31
Q

What’s the quick way to write a method that prints out a string?

A

Write sout
which prints a string to System.out

32
Q

Read this code:

“public class Main {
public static void main(String[] args) {
}

public static void giveGreeting() {
System.out.println(“Hello World”);

}
}”
When trying to run this code, nothing displayed on the console. Why?

A

Because the ‘sayGreatings’ method was written outside the ‘main’ method which is the starting point of execution. When this starting point is empty, the compiler won’t find a code to execute and thus nothing appears on the console

33
Q

You used this combo of keyboard buttons on a line of code: shift+alt+down arrow
What’s the expected change?

A

This code line will move under the next line in order

34
Q

Is it preferable to name a method descriptively?

A

Yes. A descriptive naming of a method makes it easier to know what the method will probably entail

35
Q

You want to call a method called ‘tryRing’ (created on Class1) on Class2, what will you write?

A

In the tab of Class2, I’ll write:
Class1.tryHelp()

Explanation: write the class name then the dot operation and choose the method that was created in that class

36
Q

What’s an “Access Modifier”?

A

It’s a keyword that determines the level of accessibility or visibility a class, method or variables has in relation to other parts of the program

37
Q

Is ‘static’ an access or non-access modifier, and explain further

A

static is a non-access modifier
Our ability to access an object (or field) or methods using its name is due to this keyword ‘static

38
Q

If we want to confine a method only to its class, what keyword to ise in its declaration?

A

Private’ keyword
It ensures that the access level is only inside the class

39
Q

In a java program, this code was written:
public String chooseColour(String colour) {
return colour

public static void main (String [] ergs) {
System.out.print(“Your choice “ + chooseColour (purple) + “indicates something about your personality”
}

Did the method take an input from the user? What is the type of its return?

A

• No, it didn’t take input from the user. Inputs are taken via a Scanner object. However, the value was assigned to the parameter (the variable which is name) when the method was called and given a value of “purple”.
• Type of return is: String.
The return type is the same as the value type.

40
Q

What is meant by ‘Command line arguments’?

A

They are the data (Strings) given to the main method which can be used accordingly

41
Q

How to write the main method in an organized fashion in its line? What’s this process called

A

• We should leave a tab (= 4 spaces) at the beginning of the line
• It’s calledindentation

42
Q

What’s‘End-of-line’ code block style? Mention another style that can be used.
Which one of those is used in java API source code?

A

• It’s a style of putting the curly braces ,between which the code is blocked, at the end of the same line that starts the code block
• Another style is: next-line style

• End-of-line style is used in java API

43
Q

What shortcut in keyboard can you use to get to the begining of line?

A

home” button

44
Q

How to move the cursor word by word using keyboard?

A

Using:
Cntrl + Right or left arrows in the keyboard

45
Q

How to get to the begining of the file using shortcuts in the keyboard?

A

Press pg up

46
Q

In order to select a code block using keyboard shortcuts, which of the following is correct?
A) shift + up or down arrows
B) shift + alt + up or down arrows
C) ctrl + W

A

C) ctrl + W
For each press on these two, a bigger block is selected

47
Q

What’s the function of the “tab” button on the keyboard?

A

It can be used as a shortcut for indentation.
Typically when pressed, it’ll leave 4 spaces and for each press it’ll move another 4 spaces (another ident).

48
Q

If you put an ident using tab button but wish to quit that ident and go back ident by ident, what will you do?

A

I will use this shortcut:
shift + tab

49
Q

How to duplicate a statement using keyboard shortcuts?

A

When the cursor is anywhere on the line, press “ctrl + D

50
Q

You used ctrl + / on a line, what is the expected outcome?

A

That line will be a comment
And to remove the commenting, we use the same shortcut again.