Flashcards
Java Basics
Cards in this deck (24)
- 1members of a classmethods and fields
- 2no value at all will be returnedvoid
- 3how is called the full declaration of a method?method signature
- 4after compiling a .java what is the content of the created file?a file of bytecode by the same name with .class extension
- 5how to import all classes in a packages ?using a wildcard
java.util.*;
it does't slow down the program because the compiler figures out what's actually needed - 6how to import the System class?import java.lang.System;
It is not necessary because all the java.lang package is always automatically imported - 7how do I import a class that is in the same package?You don't need to.
- 8Can i import child packages with a wildcard? I need: java.nio.files.Paths Should I use: java.nio.*No, wildcards only matches class names.
- 9what will happen? import java.util.*; import java.sql.*;Compiler error:
The type Date is ambiguous.
import java.util.Date;
import java.sql.*;
A explicitly class name import has precedence over any wildcard.
You could use fully qualified class name. - 10how to import the class ArrayList?import java.util.ArrayList;
- 11Is this a constructor? public void Chick() { }No, constructors don't have a return type.
- 12How many and what are the primitive types of Java?8
boolean
byte
char
short, int, long
float, double - 13What are the basic differences between the primitive types in Java and C?In Java they all have a fixed length.
- 14boolean (size, type)1 bit
true / false - 15byte (size, type, range)8 bits
integral value
-128, 127
from -(2^7) to (2^7-1) - 16short (size, type, range)16 bits
integer value
-32.768, 32.767
from -(2^15) to (2^15-1) - 17int (size, type, range)32 bits
integer value
-2.147.483.648, 2.147.483.647
from -(2^31) to (2^31-1) - 18long (size, type, range)64 bits
integer value
~ -9*10^18, 9*10^18
from -(2^63) to (2^63-1) - 19float (size, type, range)32 bits
floating-point value
123.45f - 20double (size, type, range)64 bits
floating-point value
123.456 - 21char16 bits
Unicode value
'a' - 22How would you insert a literal float in the code? What about long, octal, hex, bin?123.5f
adding an "f" at the end of the number
LONG: 334.444L (upper case L plx)
Octal: 0545
Hexadecimal: 0x345
Binary: 0b10110 - 23is this right? int num = 3_000_023;Yes, since Java 7 you can add underscores in numbers to make them easier to read.
notAtStart = _1000.00; WRONG
notAtEnd = 1000.00_; // WRONG
notByDecimal = 1000_.00; // WRONG
annoyingButLegal = 1_00_0.0_0; // OK - 24Is this right? String nome = "Tiago"; int idade = null;Primitive types cannot be assigned to null.
Information
- Description
- Oracle Certified Associate Oracle Certified Associate Flashcards on Java Basics, created by ferreirati on 24/12/2015.
- Created by
- ferreirati
- Views
- 11
- Rating