PRO192.part5

¡Supera tus tareas y exámenes ahora con Quizwiz!

a

Which method can be defined only once in a program? a) main method b) finalize method c) static method d) private method

d

Which of the following is a method having same name as that of it's class? a) finalize b) delete c) class d) constructo

c

What is the output of this program? class box { int width; int height; int length; int volume; void volume() { volume = width*height*length; } } class Output { public static void main(String args[]) { box obj = new box(); obj.height = 1; obj.length = 5; obj.width = 5; obj.volume(); System.out.println(obj.volume); } } a) 0 b) 1 c) 25 d) 26

c

What is the output of this program? class box { int width; int height; int length; int volume; void volume(int height, int length, int width) { volume = width*height*length; } } class Prameterized_method{ public static void main(String args[]) { box obj = new box(); obj.height = 1; obj.length = 5; obj.width = 5; obj.volume(3,2,1); System.out.println(obj.volume); } } a) 0 b) 1 c) 6 d) 25

a

Which of the following statement is correct? a) reverse() method reverses all characters. b) reverseall() method reverses all characters. c) replace() method replaces first occurrence of a character in invoking string with another character. d) replace() method replaces last occurrence of a character in invoking string with another character.

d

Which of these can be returned by the operator & ? a) Integer b) Boolean c) Character d) Integer or Boolean

b

Which of these can not be used for a variable name in Java? a) identifier b) keyword c) identifier & keyword d) None of the mentioned

b

Which of these class is superclass of String and StringBuffer class? a) java.util b) java.lang c) ArrayList d) None of the mentioned

b

Which of these class is used to create an object whose character sequence is mutable? a) String() b) StringBuffer() c) Both of the mentioned d) None of the mentioned

a

Which of these constructors is used to create an empty String object? a) String() b) String(void) c) String(0) d) None of the mentioned

c

Which of these data type value is returned by equals() method of String class? a) char b) int c) boolean d) All of the mentioned

c

Which of these is an oncorrect statement? a) String objects are immutable, they cannot be changed. b) String object can point to some other reference of String variable. c) StringBuffer class is used to store string in a buffer for later use. d) None of the mentioned

d

Which of these is incorrect string literal? a) "Hello World" b) "Hello\nWorld" c) "\"Hello World\"" d) "Hello world"

a

Which of these is long data type literal? a) 0x99fffL b) ABCDEFG c) 0x99fffa d) 99671246

a

Which of these method of class String is used to check weather a given object starts with a particular string literal? a) startsWith() b) endsWith() c) Starts() d) ends()

c

Which of these method of class String is used to extract a single character from a String object? a) CHARAT() b) chatat() c) charAt() d) ChatAt()

d

Which of these method of class String is used to obtain length of String object? a) get() b) Sizeof() c) lengthof() d) length()

b

Which of these method of class StringBuffer is used to concatenate the string representation to the end of invoking string? a) concat() b) append() c) join() d) concatenate()

a

Which of these method of class StringBuffer is used to find the length of current character sequence? a) length() b) Length() c) capacity() d) Capacity()

d

Which of these methods is used to compare a specific region inside a string with another specific region in another string? a) regionMatch() b) match() c) RegionMatches() d) regionMatches()

a

Which of these operators can be used to concatenate two or more String objects? a) + b) += c) & d) ||

d

Which of these statement is incorrect? a) All object of a class are allotted memory for the all the variables defined in the class. b) If a function is defined public it can be accessed by object of other class by inheritation. c) main() method must be made public. d) All object of a class are allotted memory for the methods defined in the class.

d

What is the output of this program? class area { int width; int length; int volume; area() { width=5; length=6; } void volume() { volume = width*length*height; } } class cons_method { public static void main(String args[]) { area obj = new area(); obj.volume(); System.out.println(obj.volume); } } a) 0 b) 1 c) 30 d) error

b

What is the output of this program? class array_output { public static void main(String args[]) { int array_variable [] = new int[10]; for (int i = 0; i < 10; ++i) { array_variable[i] = i/2; array_variable[i]++; System.out.print(array_variable[i] + " "); i++; } } } a) 0 2 4 6 8 b) 1 2 3 4 5 c) 0 1 2 3 4 5 6 7 8 9 d) 1 2 3 4 5 6 7 8 9 10

a

What is the output of this program? class dynamic_initialization { public static void main(String args[]) { double a, b; a = 3.0; b = 4.0; double c = Math.sqrt(a * a + b * b); System.out.println(c); } } a) 5.0 b) 25.0 c) 7.0 d) Compilation Error

b

What is the output of this program? class equality { int x; int y; boolean isequal(){ return(x == y); } } class Output { public static void main(String args[]) { equality obj = new equality(); obj.x = 5; obj.y = 5; System.out.println(obj.isequal()); } } a) false b) true c) 0 d) 1

c

What is the output of this program? class evaluate { public static void main(String args[]) { int a[] = {1,2,3,4,5}; int d[] = a; int sum = 0; for (int j = 0; j < 3; ++j) sum += (a[j] * d[j + 1]) + (a[j + 1] * d[j]); System.out.println(sum); } } a) 38 b) 39 c) 40 d) 41

d

What is the output of this program? class output { public static void main(String args[]) { StringBuffer c = new StringBuffer("Hello"); StringBuffer c1 = new StringBuffer(" World"); c.append(c1); System.out.println(c); } } a) Hello b) World c) Helloworld d) Hello World

d

What is the output of this program? class output { public static void main(String args[]) { StringBuffer c = new StringBuffer("Hello"); c.delete(0,2); System.out.println(c); } } a) He b) Hel c) lo d) llo

b

What is the output of this program? class output { public static void main(String args[]) { StringBuffer s1 = new StringBuffer("Hello"); StringBuffer s2 = s1.reverse(); System.out.println(s2); } } a) Hello b) olleH c) HelloolleH d) olleHHello

d

What is the output of this program? class variable_scope { public static void main(String args[]) { int x; x = 5; { int y = 6; System.out.print(x + " " + y); } System.out.println(x + " " + y); } } a) 5 6 5 6 b) 5 6 5 c) Runtime error d) Compilation error

b

What is the process of defining more than one method in a class differentiated by method signature? a) Function overriding b) Function overloading c) Function doubling d) None of the mentioned

c

What is the return type of a method that does not returns any value? a) int b) float c) void d) double

b

What is the string contained in s after following lines of code? StringBuffer s new StringBuffer("Hello"); s.deleteCharAt(0); a) Hell b) ello c) Hel d) llo

b

What is the value returned by unction compareTo() if the invoking string is less than the string compared? a) zero b) value less than zero c) value greater than zero d) None of the mentioned

d

Literal can be of which of these data types? a) integer b) float c) boolean d) all of the mentioned

a

1. Which of these method of class String is used to compare two String objects for their equality? a) equals() b) Equals() c) isequal() d) Isequal()

c

What is the output of this program? class output { public static void main(String args[]) { String s1 = "Hello"; String s2 = new String(s1); String s3 = "HELLO"; System.out.println(s1.equals(s2) + " " + s2.equals(s3)); } } a) true true b) false false c) true false d) false true

d

What is the output of this program? class String_demo { public static void main(String args[]) { char chars[] = {'a', 'b', 'c'}; String s = new String(chars); String s1 = "abcd"; int len1 = s1.length(); int len2 = s.length(); System.out.println(len1 + " " + len2); } } a) 3 0 b) 0 3 c) 3 4 d) 4 3

d

In the below code, which call to sum() method is appropriate? class Output { public static int sum(int ...x) { return; } static void main(String args[]) { sum(10); sum(10,20); sum(10,20,30); sum(10,20,30,40); } } a) only sum(10) b) only sum(10,20) c) only sum(10) & sum(10,20) d) all of the mentioned

d

In the below code, which code fragment should be inserted at line 3 so that the output will be: "123abc 123abc"? 1 StringBuilder sb1 = new StringBuilder("123"); 2 String s1 = "123"; 3 // insert code here 4 System.out.println(sb1 + " " + s1); a) sb1.append("abc"); s1.append("abc"); b) sb1.append("abc"); s1.concat("abc"); c) sb1.concat("abc"); s1.append("abc"); d) sb1.append("abc"); s1 = s1.concat("abc");

d

What is the output of this program? class String_demo { public static void main(String args[]) { char chars[] = {'a', 'b', 'c'}; String s = new String(chars); System.out.println(s); } } a) a b) b c) c d) abc

d

Literals in java must be appended by which of these? a) L b) l c) D d) L and I

b

What is the output of this program? class String_demo { public static void main(String args[]) { int ascii[] = { 65, 66, 67, 68}; String s = new String(ascii, 1, 3); System.out.println(s); } } a) ABC b) BCD c) CDA d) ABCD

c

What is the output of this program? class A { int i; int j; A() { i = 1; j = 2; } } class Output { public static void main(String args[]) { A obj1 = new A(); System.out.print(obj1.toString()); } } a) true b) false c) String associated with obj1 d) Compilation Error

c

What is the output of this program? class output { class output { public static void main(String args[]) { char c[]={'A', '1', 'b' ,' ' ,'a' , '0'}; for (int i = 0; i < 5; ++i) { i++; if(Character.isDigit(c[i])) System.out.println(c[i]+" is a digit"); if(Character.isWhitespace(c[i])) System.out.println(c[i]+" is a Whitespace character"); if(Character.isUpperCase(c[i])) System.out.println(c[i]+" is an Upper case Letter"); if(Character.isLowerCase(c[i])) System.out.println(c[i]+" is a lower case Letter"); i++; } } } a) a is a lower case Letter is White space character b) b is a lower case Letter is White space character c) 1 is a digit a is a lower case Letter d) a is a lower case Letter 0 is a digit

a

What is the output of this program? class output { public static void main(String args[]) { String a = "hello i love java"; System.out.println(a.indexOf('e')+" "+a.indexOf('a')+" "+a.lastIndexOf('l')+" "+a.lastIndexOf('v')); } } a) 6 4 6 9 b) 5 4 5 9 c) 7 8 8 9 d) 1 14 8 15

d

What is the output of this program? class output { public static void main(String args[]) { String chars[] = {"a", "b", "c", "a", "c"}; for (int i = 0; i < chars.length; ++i) for (int j = i + 1; j < chars.length; ++j) if(chars[i].compareTo(chars[j]) == 0) System.out.print(chars[j]); } } a) ab b) bc c) ca d) ac

b

What is the output of this program? class output { public static void main(String args[]) { String c = "Hello i love java"; boolean var; var = c.startsWith("hello"); System.out.println(var); } } a) true b) false c) 0 d) 1

d

What is the output of this program? class output { public static void main(String args[]) { String s1 = "Hello i love java"; String s2 = new String(s1); System.out.println((s1 == s2) + " " + s1.equals(s2)); } } a) true true b) false false c) true false d) false true


Conjuntos de estudio relacionados

S3 Practice Written Comp #2 (4/19/23 ) - 37/73

View Set

Chapter 7 - Medication Order Entry & Fill Process

View Set

Earth Science Glossary - Tarbuck & Lutgens

View Set

Algebra 1 - Functions & Graphing

View Set

Lesson 1: How Current Reacts in DC Parallel Circuits

View Set

La cultura de los países hispanos

View Set

B&G Chptr 8 communication Systems

View Set