Question 21 The method __________ sets the font (Helvetica, 20point bold) in co
ID: 3581206 • Letter: Q
Question
Question 21
The method __________ sets the font (Helvetica, 20point bold) in component C.
a) c.setFont(new Font("Helvetica", Font.bold, 20))
b) c.setFont(new Font("helvetica", BOLD, 20))
c) c.setFont(Font("Helvetica", Font.BOLD, 20))
d) c.setFont(new Font("Helvetica", Font.BOLD, 20))
Question 22
To specify an italic font, you pass ____ to the constructor.
a) Font.ITALIC
b) Font.BOLD
c) PLAIN.ITALIC
d) ITALIC
Question 23
Which class do you use to read data from a text file?
a) File
b) Formatter
c) Scanner
d) Input
Question 24
An attribute that is shared by all objects of the class is coded using _____________.
a) an instance variable
b) a static instance variable
c) an instance method
d) a static method
Question 25
Usually, the subclass constructor only needs to initialize the ____ that are specific to the subclass.
a) objects
b) data fields
c) methods
d) constructors
Question 26
When you instantiate an object from a class, ____ is reserved for each instance field in the class.
a) a constructor
b) a signature
c) memory
d) a field name
Question 27
Select appropriate method out of number of methods' definitions at execution time is called _______.
a) Compiling
b) Static binding
c) Dynamic binding
d) Matching
Question 28
An abstract class can contain ____.
a) only abstract methods
b) only nonabstract methods
c) abstract and nonabstract methods
d) nothing
Question 29
When you create a class and do not provide a(n) ____, Java automatically supplies you with a default one.
a) constructor
b) argument
c) header
d) name
Question 30
Which of the following is used to allocate memory for the instance variables of an object of a class?
a) the reserved word public
b) the reserved word static
c) the operator new
d) the operator +
Question 31
Which of the following correctly declares and initializes a String object?
a) new String = Hello
b) String greeting == "Hello"
c) String greeting = "Hello"
d) String new = "Hello"
Question 32
Imageobjects are displayed using which Graphicsmethod?
a) drawImage.
b) paintImage.
c) getImage.
d) setImage.
Question 33
What layout manager should you use so that every component occupies the same size in the container?
a) a FlowLayout
b) a GridLayout
c) a BorderLayout
d) any layout
Question 34
When an object of one class is a data field within another class, they are related by ____.
a) extension
b) scope
c) composition/hasa
d) isa
Question 35
The ____ method takes a String argument and returns its double value.
a) parseString()
b) parseInt()
c) parseDouble()
d) returnDouble()
Question 36
The compiler determines which version of a method to call by the method’s ____.
a) name
b) signature
c) output
d) constructor
Question 37
Which JFrameJFrame method is used to display the frame?
a) Display().
b) Load().
c) setVisible(true)
d) show(true)
Question 38
___________ can be used to enter or display a string.
a) A label
b) A button
c) A check box
d) A radio button
e) A text field
Question 39
The ____ method creates a solid arc.
a) solidArc()
b) fillArc()
c) clearArc()
d) drawArc()
Question 40
Which method can be used to create an input object for file temp.txt?
a) new Scanner("temp.txt")
b) new Scanner(temp.txt)
c) new Scanner(Paths.get("temp.txt"))
d) new Scanner(Path("temp.txt"))
Question 42
What happens in a method if there is an exception thrown in a try block but there is no catch block following the try block?
a) The program ignores the exception.
b) The program will not compile without a complete try/catch structure.
c) The program terminates immediately.
d) The program throws an exception and proceeds to execute the finally block.
Question 43
Which of the following words indicates an object’s reference to itself?
a) this
b) that
c) public
d) protected
Question 44
Suppose s is a string with the value "java". What will be assigned to x if you execute the following code? char x = s.charAt(4)
a) "a"
b) "v"
c) Nothing due to a runtime error StringIndexOutofBoundsException
d) "java"
Question 45
____ variables are variables that are shared by every instantiation of a class.
a) Local
b) Instance
c) Class/Static
d) Time
Question 46
Which of the following statements starts a polygon named pol at the coordinates 20 and 290?
a) pol.moveTo(20F, 290F)
b) pol.lineTo(20F, 290F)
c) pol = new Path(20F, 290F)
d) pol.newPath(20F, 290F)
Question 47
Suppose str is a String variable. The statement
str = new String("Programming")
is similar to which of the following?
a) new String = "Programming"
b) String new = "Programming"
c) str = "Programming"
d) str new "Programming"
Question 48
The ____ method requires four arguments and draws the outline of a rectangle using the current drawing color.
a) clearRect()
b) drawRect()
c) fillRect()
d) paintRect()
Question 49
Which of the following is a valid statement?
(i) int num = new int(67)
(ii) String name = new ("Doe")
(iii) String name = "Doe"
a) Only (i)
b) Only (i) and (ii)
c) Only (iii)
d) Only (ii) and (iii)
Question 50
Which of the following generates GUI events?
a) Typing in a text field.
b) Selecting an item from a menu.
c) Click on a button
d) All of above
Explanation / Answer
21)ans)d
22)Ans)a
23)ans)c
24)ans)d
25)ans)b
26)ans)c
27)ans)c
28)ans)c
29)ans)a
30)ans)c
31)ans)c
32)ans)a
33)ans)b
34)ans)d
35)ans)b
36)ans)b
37)ans)c
38)ans)e
39)ans)b
40)ans)c
42)ans)d
43)ans)a
44)ans)c
45)ans)c
46)ans)a
47)ans)c
48)ans)b
49)ans)c
50)ans)d
_____________Thank You
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.