O GoConqr está de visual novo! Conte para nós o que você achou.

Quiz

CSE 1322 FINAL

Emily Mack 67 perguntas

Fazer o quiz

Perguntas do quiz (67)

  1. 1The following code will not compile as is. It is missing a line that needs to be inserted where the "//Missing Line" comment is. Which line of code will fix the compile error?

    class House {
    public int square_footage;
    public int stories;

    public House() {
    square_footage=0;
    stories=1;
    }
    }

    class Main {
    public static void main(String[] args) {
    House h1;
    //Missing Line
    h1.square_footage=1;
    }
    }
    1. Anew House(h1);
    2. Bh1 = new House();
    3. Ch1.stories = 1;
    4. Dh1.House();
  2. 2A method with a return type of void may still have a return statement in its code.
    1. AVerdadeiro
    2. BFalso
  3. 3Which of the following are valid variable declarations? (Select ALL that are valid)
    1. Aint a = 1102;
    2. Blong b=1;
    3. CJava:
      String c = 7;
      C#:
      string c = 7;
    4. DJava:
      String d= "";
      C#:
      string d= "";
    5. EJava:
      String e = "a" + "b" + 7;
  4. 4What is the output of the following code?
    Java:
    class Numbers {
    public int a;
    public static int b;

    public Numbers(int c) {
    a+=c;
    b+=c;
    }

    public int get_b() {
    return b;
    }
    }
    class Main {
    public static void main(String[] args) {
    Numbers n1=new Numbers(2);
    Numbers n2=new Numbers(3);

    System.out.println("a: "+n2.a+" b: "+Numbers.b);
    }
    }
    1. Aa: 3 b: 2
    2. Ba: 3 b: 3
    3. Ca: 3 b: 0
    4. Da: 3 b: 5
  5. 5Which of the following blocks of code will successfully as a user for a number, multiply by 2, and print the result.
    1. Aimport java.util.Scanner;
      System.out.println("Enter a number to be doubled:");
      Scanner myscanner = new Scanner(System.in);
      String num=myscanner.NextLine();
      num*=2;
      System.out.println("Your number doubled is "+num);
    2. Bimport java.util.Scanner;
      System.out.println("Enter a number to be doubled:");
      Scanner myscanner = new Scanner(System.in);
      int num=myscanner.nextInt();
      num*=2;
      System.out.println("Your number doubled is "+num);
    3. Cimport java.util.Scanner;
      int num;
      System.out.println("Enter a number to be doubled:");
      Scanner myscanner = new Scanner(System.in);
      myscanner.nextInt(num);
      num*=2;
      System.out.println("Your number doubled is "+num);
  6. 6Which of the following statements are valid?
    1. AA constructor can return a integer
    2. BA constructor can return a char
    3. CA constructor cannot return anything
    4. DA constructor can return a void
  7. 7What is the output of the following statements:

    //Java:

    String s="Hi";
    for(int i=0;i<3;i++) {
    System.out.print("S"+s);
    }
    //C#:


    string s="Hi";
    for(int i=0;i<3;i++) {
    Console.Write("S"+s);
    }
    1. AHi
    2. BHiHiHi
    3. CSHiSHiSHi
    4. DSHiSHi
  8. 8What does the following code output?
    char letters[]=new char[5];

    letters[0]='a';
    letters[1]='b';
    letters[2]='c';
    letters[3]='d';
    letters[4]='e';

    String x="";
    for(int i=4;i>=2;i--) {
    x+=letters[i];
    }
    System.out.println(x);
    1. Aabcd
    2. Bedcb
    3. Ced
    4. Dedc
  9. 9What is the output of the following code?
    class Main {
    public static void swap(String str1, String str2) {
    String holdString;
    holdString = str1;
    str1 = str2;
    str2 = holdString;
    }

    public static void main(String[] args) {
    String s1 = "Computers";
    String s2 = "Rock";
    swap(s1, s2);
    System.out.println(s1+" "+s2);
    }
    }
    1. AComputers Rock
    2. BRock Computers
    3. CComputers Computers
    4. DRock Rock
  10. 10What is the output of the following code?
    class Main {
    public static void addtwo(int[] numArray) {
    numArray[0]+=2;
    }

    public static void main(String[] args) {
    int[] myNumbers = new int[] {1,2,3,4,5};

    System.out.println(myNumbers[0]);
    }
    }
    1. A1
    2. B2
    3. C3
    4. D4

Informações

Descrição
Computer Science Quiz sobre CSE 1322 FINAL, criado por Emily Mack em 31-07-2022.
Idioma
English
Visualizações
0
Etiquetas
computer science
Avaliação
Ainda sem avaliações
Avalie este quiz
Avalie este quiz

Fale Conosco

Sobre o que é sua mensagem?

O que você acha do novo visual?

Você gostou?